Commit 37e4aa6
fix(profile): correct anon fallback in feeds, comments, notifications (#368)
Three bugs converged to make valid profiles render as Anon Chef
across feeds, comments, AuthorName, and ProfileLink — even though
the same profiles loaded fine elsewhere on Nostr. All three are
fixed in this PR.
1) getUsername now checks display_name before name. Mirrors the
priority order getDisplayName already uses. Previously
getUsername (and formatDisplayName, which wraps it) ignored
display_name entirely and fell straight to anon for profiles
that set only display_name. This affected most rendering paths
in the app since formatDisplayName is the default helper used
by feed, comments, AuthorName, and ProfileLink. Notifications
were unaffected because they call getDisplayName directly.
2) AuthorName drops its 3s outer Promise.race timeout. The inner
resolveProfileByPubkey + fetchProfileFromRelays already cap the
fetch at 5s. The 3s outer race fired before the underlying 5s
could complete on slow relays — the profile arrived in the cache
afterward, but AuthorName had already rendered the anon fallback
and uses onMount, not reactive, so it never re-read. User refresh
= re-mount = cache hit = correct render. That's the symptom
pattern reported.
3) fetchProfileFromRelays now uses an explicit relay set unioning
the connected NDK pool with canonical profile relays (purplepag.es,
relay.nostr.band, nostr.wine). NDK's user.fetchProfile() doesn't
let us override the relay set; we drop down to fetchEvent +
manual JSON parse to get the wider net. Profiles that live only
on purplepag.es or relays not in our default pool are now
reachable. Plus we now read displayName (camelCase) in addition
to display_name (snake_case) since some clients write only the
camelCase form.
Test plan:
- Profile with display_name only renders correctly in feed, comments,
AuthorName, ProfileLink (Bug 1).
- Profile that takes 4s to resolve no longer flashes anon and stick
(Bug 2). Cache eventually warms and second-mount components show
the right name without a refresh.
- Profile that lives only on purplepag.es renders without needing
the user to manually add the relay (Bug 3).
Validation:
- pnpm test 77 / 77 passing
- pnpm check 0 errors
- pnpm build clean
Out of scope:
- Reactive re-read when cache populates after the component mounts.
Would let "anon → real name" upgrade live without re-mount, but
needs a Svelte store-backed cache. Tracked as a follow-up; the
cache + faster lookups land in this PR cover most cases already.
Co-authored-by: spe1020 <sethsager@Seths-MacBook-Air.local>
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent 5fe45bc commit 37e4aa6
3 files changed
Lines changed: 97 additions & 29 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
4 | | - | |
| 4 | + | |
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
54 | 54 | | |
55 | 55 | | |
56 | 56 | | |
57 | | - | |
58 | | - | |
59 | | - | |
60 | | - | |
61 | | - | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
62 | 65 | | |
63 | 66 | | |
64 | 67 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
79 | 79 | | |
80 | 80 | | |
81 | 81 | | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
82 | 97 | | |
83 | 98 | | |
84 | 99 | | |
| |||
90 | 105 | | |
91 | 106 | | |
92 | 107 | | |
93 | | - | |
94 | | - | |
95 | | - | |
96 | | - | |
97 | | - | |
98 | | - | |
99 | | - | |
100 | | - | |
101 | | - | |
102 | | - | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
103 | 137 | | |
104 | 138 | | |
105 | | - | |
106 | | - | |
107 | | - | |
108 | | - | |
109 | | - | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
110 | 151 | | |
111 | 152 | | |
112 | 153 | | |
113 | | - | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
114 | 169 | | |
115 | | - | |
116 | | - | |
117 | | - | |
118 | | - | |
119 | | - | |
120 | | - | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
121 | 176 | | |
122 | 177 | | |
123 | 178 | | |
| |||
229 | 284 | | |
230 | 285 | | |
231 | 286 | | |
232 | | - | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
233 | 294 | | |
234 | 295 | | |
235 | 296 | | |
236 | 297 | | |
237 | 298 | | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
238 | 303 | | |
239 | 304 | | |
240 | 305 | | |
| |||
0 commit comments