@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.
@@ -1733,6 +1733,7 @@ var NostrTransportProvider = class {
1733
1733
  this.mainSubscriptionId = null;
1734
1734
  this.walletSubscriptionId = null;
1735
1735
  this.chatSubscriptionId = null;
1736
+ this.chatEoseFired = false;
1736
1737
  this.status = "disconnected";
1737
1738
  this.emitEvent({ type: "transport:disconnected", timestamp: Date.now() });
1738
1739
  logger.debug("Nostr", "Disconnected from all relays");
@@ -2056,6 +2057,20 @@ var NostrTransportProvider = class {
2056
2057
  this.typingIndicatorHandlers.add(handler);
2057
2058
  return () => this.typingIndicatorHandlers.delete(handler);
2058
2059
  }
2060
+ onChatReady(handler) {
2061
+ if (this.chatEoseFired) {
2062
+ try {
2063
+ handler();
2064
+ } catch {
2065
+ }
2066
+ return () => {
2067
+ };
2068
+ }
2069
+ this.chatEoseHandlers.push(handler);
2070
+ return () => {
2071
+ this.chatEoseHandlers = this.chatEoseHandlers.filter((h) => h !== handler);
2072
+ };
2073
+ }
2059
2074
  // ===========================================================================
2060
2075
  // Composing Indicators (NIP-59 kind 25050)
2061
2076
  // ===========================================================================
@@ -2773,6 +2788,9 @@ var NostrTransportProvider = class {
2773
2788
  // Track subscription IDs for cleanup
2774
2789
  walletSubscriptionId = null;
2775
2790
  chatSubscriptionId = null;
2791
+ // Chat EOSE handlers — fired once when relay finishes delivering stored DMs
2792
+ chatEoseHandlers = [];
2793
+ chatEoseFired = false;
2776
2794
  async subscribeToEvents() {
2777
2795
  logger.debug("Nostr", "subscribeToEvents called, identity:", !!this.identity, "keyManager:", !!this.keyManager, "nostrClient:", !!this.nostrClient);
2778
2796
  if (!this.identity || !this.keyManager || !this.nostrClient) {
@@ -2862,6 +2880,16 @@ var NostrTransportProvider = class {
2862
2880
  },
2863
2881
  onEndOfStoredEvents: () => {
2864
2882
  logger.debug("Nostr", "Chat subscription ready (EOSE)");
2883
+ if (!this.chatEoseFired) {
2884
+ this.chatEoseFired = true;
2885
+ for (const handler of this.chatEoseHandlers) {
2886
+ try {
2887
+ handler();
2888
+ } catch {
2889
+ }
2890
+ }
2891
+ this.chatEoseHandlers = [];
2892
+ }
2865
2893
  },
2866
2894
  onError: (_subId, error) => {
2867
2895
  logger.debug("Nostr", "Chat subscription error:", error);