Fix missing profile names and pictures due to stream timing
When a view subscribes to profile updates via streamProfile() or streamProfiles(), the stream now immediately yields any existing profile data from NostrDB before waiting for network updates. Previously, subscribers had to wait up to ~1 second for the subscriptionSwitcherTask to restart the profile listener before receiving any data. During this window, views would display abbreviated pubkeys (e.g., "npub1abc...") or robohash placeholders instead of the cached profile name and picture. The fix adds a simple NDB lookup when creating the stream. This has negligible performance impact since: - It's a one-time operation per subscription (not per update) - The same lookup was already happening in view bodies anyway - NDB lookups are fast local queries A new `yieldCached` parameter (default: true) allows callers to opt out of the initial cached emission. NoteContentView uses this to avoid redundant artifact re-renders — it only needs network updates since its initial render already uses cached profile data. Furthermore, when a profile has no metadata, the display name now shows "npub1yrse...q9ye" instead of "1yrsedhw:8q0pq9ye" for a better UX. Closes: https://github.com/damus-io/damus/issues/3454 Closes: https://github.com/damus-io/damus/issues/3455 Changelog-Changed: Changed abbreviated pubkey format to npub1...xyz for better readability Changelog-Fixed: Fixed instances where a profile would not display profile name and picture for a few seconds Signed-off-by: alltheseas <64376233+alltheseas@users.noreply.github.com> Co-authored-by: Daniel D’Aquino <daniel@daquino.me>
This commit is contained in:
@@ -1669,6 +1669,7 @@
|
||||
D74EC8522E1856B70091DC51 /* NonCopyableLinkedList.swift in Sources */ = {isa = PBXBuildFile; fileRef = D74EC84E2E1856AF0091DC51 /* NonCopyableLinkedList.swift */; };
|
||||
D74F430A2B23F0BE00425B75 /* DamusPurple.swift in Sources */ = {isa = PBXBuildFile; fileRef = D74F43092B23F0BE00425B75 /* DamusPurple.swift */; };
|
||||
D74F430C2B23FB9B00425B75 /* StoreObserver.swift in Sources */ = {isa = PBXBuildFile; fileRef = D74F430B2B23FB9B00425B75 /* StoreObserver.swift */; };
|
||||
D751FA992EF62C8100E10F1B /* ProfilesManagerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = D751FA982EF62C8100E10F1B /* ProfilesManagerTests.swift */; };
|
||||
D753CEAA2BE9DE04001C3A5D /* MutingTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = D753CEA92BE9DE04001C3A5D /* MutingTests.swift */; };
|
||||
D755B28D2D3E7D8800BBEEFA /* NIP37Draft.swift in Sources */ = {isa = PBXBuildFile; fileRef = D755B28C2D3E7D7D00BBEEFA /* NIP37Draft.swift */; };
|
||||
D755B28E2D3E7D8800BBEEFA /* NIP37Draft.swift in Sources */ = {isa = PBXBuildFile; fileRef = D755B28C2D3E7D7D00BBEEFA /* NIP37Draft.swift */; };
|
||||
@@ -2768,6 +2769,7 @@
|
||||
D74EC84E2E1856AF0091DC51 /* NonCopyableLinkedList.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NonCopyableLinkedList.swift; sourceTree = "<group>"; };
|
||||
D74F43092B23F0BE00425B75 /* DamusPurple.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DamusPurple.swift; sourceTree = "<group>"; };
|
||||
D74F430B2B23FB9B00425B75 /* StoreObserver.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StoreObserver.swift; sourceTree = "<group>"; };
|
||||
D751FA982EF62C8100E10F1B /* ProfilesManagerTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProfilesManagerTests.swift; sourceTree = "<group>"; };
|
||||
D753CEA92BE9DE04001C3A5D /* MutingTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MutingTests.swift; sourceTree = "<group>"; };
|
||||
D755B28C2D3E7D7D00BBEEFA /* NIP37Draft.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NIP37Draft.swift; sourceTree = "<group>"; };
|
||||
D76556D52B1E6C08001B0CCC /* DamusPurpleWelcomeView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DamusPurpleWelcomeView.swift; sourceTree = "<group>"; };
|
||||
@@ -5278,6 +5280,7 @@
|
||||
D7EBF8BC2E5946F9004EAE29 /* NostrNetworkManagerTests */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
D751FA982EF62C8100E10F1B /* ProfilesManagerTests.swift */,
|
||||
D7EBF8BD2E594708004EAE29 /* test_notes.jsonl */,
|
||||
D7EBF8BA2E5901F7004EAE29 /* NostrNetworkManagerTests.swift */,
|
||||
D7EBF8BF2E5D39D1004EAE29 /* ThreadModelTests.swift */,
|
||||
@@ -6252,6 +6255,7 @@
|
||||
4C0ED07F2D7A1E260020D8A2 /* Benchmarking.swift in Sources */,
|
||||
3A3040ED29A5CB86008A0F29 /* ReplyDescriptionTests.swift in Sources */,
|
||||
D71DC1EC2A9129C3006E207C /* PostViewTests.swift in Sources */,
|
||||
D751FA992EF62C8100E10F1B /* ProfilesManagerTests.swift in Sources */,
|
||||
3AAC7A022A60FE72002B50DF /* LocalizationUtilTests.swift in Sources */,
|
||||
D7CBD1D62B8D509800BFD889 /* DamusPurpleImpendingExpirationTests.swift in Sources */,
|
||||
D7EBF8BB2E59022A004EAE29 /* NostrNetworkManagerTests.swift in Sources */,
|
||||
|
||||
Reference in New Issue
Block a user