mirror of
https://github.com/PR0M3TH3AN/bitvid.git
synced 2026-10-30 01:12:39 +00:00
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:
1 parent
92d0766516
commit
63d4b3ffd1
3 files changed
+14
-1
No files matched your search
@@ -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.", {
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -4970,7 +4970,10 @@ export class ProfileModalController {
|
||||
}
|
||||
|
||||
handleDirectMessagesUpdated(detail = {}) {
|
||||
if (this.activeMessagesRequest) {
|
||||
if (
|
||||
this.activeMessagesRequest &&
|
||||
detail?.reason !== "load-incremental"
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user