feat(dm): implement incremental delivery for direct messages

- Added `onMessage` callback to `NostrClient.listDirectMessages` to stream decrypted messages.
- Updated `NostrService.loadDirectMessages` to use the callback and trigger `applyDirectMessage` incrementally.
- Updated `ProfileModalController` to allow rendering updates during the initial load if the reason is `load-incremental`.
- Verified changes with existing tests and code review.

Co-authored-by: PR0M3TH3AN <[email protected]>
This commit is contained in:
google-labs-jules[bot]andPR0M3TH3AN committed 2026-01-28 00:11:32 +00:00
1 parent 92d0766516
commit 63d4b3ffd1
3 files changed
+14 -1

No files matched your search

+7
View File
@@ -4480,6 +4480,13 @@ export class NostrClient {
});
if (decrypted?.ok) {
messages.push(decrypted);
if (typeof options.onMessage === "function") {
try {
options.onMessage(decrypted);
} catch (error) {
devLogger.warn("[nostr] onMessage callback threw:", error);
}
}
}
} catch (error) {
devLogger.warn("[nostr] Failed to decrypt DM event during list.", {
+3
View File
@@ -958,6 +958,9 @@ export class NostrService {
...options,
limit: resolvedLimit,
decryptLimit: resolvedDecryptLimit,
onMessage: (message) => {
this.applyDirectMessage(message, { reason: "load-incremental" });
},
});
} catch (error) {
userLogger.warn("[nostrService] Failed to load direct messages", error);
+4 -1
View File
@@ -4970,7 +4970,10 @@ export class ProfileModalController {
}
handleDirectMessagesUpdated(detail = {}) {
if (this.activeMessagesRequest) {
if (
this.activeMessagesRequest &&
detail?.reason !== "load-incremental"
) {
return;
}