Skip to content

fix: user profile image upload issue#369

Merged
calvadev merged 8 commits intoshopstr-eng:mainfrom
wolgwang1729:fix/profile-upload-image
Apr 14, 2026
Merged

fix: user profile image upload issue#369
calvadev merged 8 commits intoshopstr-eng:mainfrom
wolgwang1729:fix/profile-upload-image

Conversation

@wolgwang1729
Copy link
Copy Markdown
Contributor

Description

  • Fixes the profile image upload flow to prevent UI reversion and runtime edge-case failures after upload.
  • Hardens form input handling for numeric fields by safely converting optional values to string using value?.toString() || "" in both profile form implementations.
  • Improves uploader reliability by only setting loading state when files actually exist and by filtering out falsy upload results before invoking upload callbacks.
  • Prevents accidental form submission during file upload by setting the uploader button to type="button".
  • Replaces NextUI Input with native input for file selection to avoid controlled file input conflicts.
  • Adds Blossom response normalization to support both top-level JSON fields and nip94_event.tags responses.
  • Adds a fallback URL constructor from SHA-256 hash when URL is omitted by a Blossom server and throws a clear error if no usable URL can be resolved.
  • Prevents stale context-driven profile resets in settings by guarding repeated form resets with if (contextLoadedRef.current) return;.

Screenshots (if applicable)

Previous Error:
error now

After Fix:

Shopstr.Bitcoin-Native.Nostr.Marketplace.Shop.Freely.-.Google.Chrome.-.8.April.2026_blurred.mp4

Affirmation

Copilot AI review requested due to automatic review settings April 8, 2026 05:33
@vercel
Copy link
Copy Markdown

vercel bot commented Apr 8, 2026

@wolgwang1729 is attempting to deploy a commit to the shopstr-eng Team on Vercel.

A member of the Team first needs to authorize it.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Fixes the user profile image upload flow to prevent UI reversion and improve resilience across different Blossom server response formats.

Changes:

  • Normalizes Blossom upload responses (top-level vs NIP-94 tags) and adds URL fallback construction from SHA-256 when needed.
  • Hardens profile form numeric input stringification and prevents stale context-driven resets.
  • Improves file uploader reliability (loading state, filtering upload results) and prevents accidental form submission during uploads.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.

File Description
utils/nostr/nostr-helper-functions.ts Normalizes Blossom responses and adds URL fallback + clearer error when URL can’t be resolved.
pages/settings/user-profile.tsx Guards repeated form resets and hardens numeric input value conversion.
components/utility-components/file-uploader.tsx Improves loading behavior, prevents accidental submit, and swaps to native file input.
components/settings/user-profile-form.tsx Hardens numeric input value conversion.
Comments suppressed due to low confidence (1)

components/utility-components/file-uploader.tsx:1

  • .filter((url) => Boolean(url)) doesn’t provide TypeScript narrowing (unlike a type-predicate), so the resulting array type may remain a union (e.g., (string | null)[]). If later code expects string[], prefer a type guard filter such as (url): url is string => typeof url === \"string\" && url.length > 0 (or at least url != null) to keep type safety.
import { useContext, useRef, useState } from "react";

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread utils/nostr/nostr-helper-functions.ts Outdated
Comment thread utils/nostr/nostr-helper-functions.ts
Comment thread components/utility-components/file-uploader.tsx
@GautamBytes
Copy link
Copy Markdown
Contributor

can u solve the conflict?
ping me for review then

@wolgwang1729 wolgwang1729 force-pushed the fix/profile-upload-image branch from 833e2c9 to e4d73ee Compare April 12, 2026 10:21
Copy link
Copy Markdown
Contributor

@GautamBytes GautamBytes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pages/settings/user-profile.tsx still does DB-first hydration and writes back created_at: 0, and the new contextLoadedRef can block fresher profileContext updates after that. Please switch this page to the same timestamped recency/local-fallback logic as components/settings/user-profile-form.tsx so stale data can’t win after an image upload.

@wolgwang1729
Copy link
Copy Markdown
Contributor Author

Great catch! I initially held off on changing the hydration approach in user-profile.tsx because it felt a bit outside the original scope of this PR, but I completely agree it's needed to prevent stale data from overriding the context.

I've now refactored both user-profile.tsx and user-profile-form.tsx to use the same timestamped local-fallback logic. The shared fallback functions are now in nostr-helper-functions.ts, so both files use a single source of truth for profile hydration.

@GautamBytes
Copy link
Copy Markdown
Contributor

LGTM Now!!

@calvadev calvadev dismissed GautamBytes’s stale review April 14, 2026 22:12

Changes implemented.

@calvadev calvadev merged commit a5c1e51 into shopstr-eng:main Apr 14, 2026
1 check failed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants