diff --git a/js/nostr/client.js b/js/nostr/client.js index 19c31fb7..05511947 100644 --- a/js/nostr/client.js +++ b/js/nostr/client.js @@ -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.", { diff --git a/js/services/nostrService.js b/js/services/nostrService.js index 9f8ce604..5d7dfe7e 100644 --- a/js/services/nostrService.js +++ b/js/services/nostrService.js @@ -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); diff --git a/js/ui/profileModalController.js b/js/ui/profileModalController.js index a03fec90..46d0edc5 100644 --- a/js/ui/profileModalController.js +++ b/js/ui/profileModalController.js @@ -4970,7 +4970,10 @@ export class ProfileModalController { } handleDirectMessagesUpdated(detail = {}) { - if (this.activeMessagesRequest) { + if ( + this.activeMessagesRequest && + detail?.reason !== "load-incremental" + ) { return; }