@unicitylabs/sphere-sdk 0.6.0 → 0.6.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1781,6 +1781,7 @@ var NostrTransportProvider = class {
1781
1781
  this.mainSubscriptionId = null;
1782
1782
  this.walletSubscriptionId = null;
1783
1783
  this.chatSubscriptionId = null;
1784
+ this.chatEoseFired = false;
1784
1785
  this.status = "disconnected";
1785
1786
  this.emitEvent({ type: "transport:disconnected", timestamp: Date.now() });
1786
1787
  logger.debug("Nostr", "Disconnected from all relays");
@@ -2104,6 +2105,20 @@ var NostrTransportProvider = class {
2104
2105
  this.typingIndicatorHandlers.add(handler);
2105
2106
  return () => this.typingIndicatorHandlers.delete(handler);
2106
2107
  }
2108
+ onChatReady(handler) {
2109
+ if (this.chatEoseFired) {
2110
+ try {
2111
+ handler();
2112
+ } catch {
2113
+ }
2114
+ return () => {
2115
+ };
2116
+ }
2117
+ this.chatEoseHandlers.push(handler);
2118
+ return () => {
2119
+ this.chatEoseHandlers = this.chatEoseHandlers.filter((h) => h !== handler);
2120
+ };
2121
+ }
2107
2122
  // ===========================================================================
2108
2123
  // Composing Indicators (NIP-59 kind 25050)
2109
2124
  // ===========================================================================
@@ -2821,6 +2836,9 @@ var NostrTransportProvider = class {
2821
2836
  // Track subscription IDs for cleanup
2822
2837
  walletSubscriptionId = null;
2823
2838
  chatSubscriptionId = null;
2839
+ // Chat EOSE handlers — fired once when relay finishes delivering stored DMs
2840
+ chatEoseHandlers = [];
2841
+ chatEoseFired = false;
2824
2842
  async subscribeToEvents() {
2825
2843
  logger.debug("Nostr", "subscribeToEvents called, identity:", !!this.identity, "keyManager:", !!this.keyManager, "nostrClient:", !!this.nostrClient);
2826
2844
  if (!this.identity || !this.keyManager || !this.nostrClient) {
@@ -2910,6 +2928,16 @@ var NostrTransportProvider = class {
2910
2928
  },
2911
2929
  onEndOfStoredEvents: () => {
2912
2930
  logger.debug("Nostr", "Chat subscription ready (EOSE)");
2931
+ if (!this.chatEoseFired) {
2932
+ this.chatEoseFired = true;
2933
+ for (const handler of this.chatEoseHandlers) {
2934
+ try {
2935
+ handler();
2936
+ } catch {
2937
+ }
2938
+ }
2939
+ this.chatEoseHandlers = [];
2940
+ }
2913
2941
  },
2914
2942
  onError: (_subId, error) => {
2915
2943
  logger.debug("Nostr", "Chat subscription error:", error);