@repzo/widget-react-native 1.2.0 → 1.2.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.
Files changed (135) hide show
  1. package/CHANGELOG.md +57 -0
  2. package/README.md +73 -1
  3. package/lib/commonjs/api/client.js +57 -2
  4. package/lib/commonjs/api/client.js.map +1 -1
  5. package/lib/commonjs/audio/voice.js +119 -0
  6. package/lib/commonjs/audio/voice.js.map +1 -0
  7. package/lib/commonjs/i18n.js +6 -0
  8. package/lib/commonjs/i18n.js.map +1 -1
  9. package/lib/commonjs/index.js +2 -1
  10. package/lib/commonjs/index.js.map +1 -1
  11. package/lib/commonjs/locales.js +4 -0
  12. package/lib/commonjs/locales.js.map +1 -1
  13. package/lib/commonjs/push/push-notifications.js +61 -6
  14. package/lib/commonjs/push/push-notifications.js.map +1 -1
  15. package/lib/commonjs/state/use-widget-state.js +31 -0
  16. package/lib/commonjs/state/use-widget-state.js.map +1 -1
  17. package/lib/commonjs/state/widget-store.js +22 -1
  18. package/lib/commonjs/state/widget-store.js.map +1 -1
  19. package/lib/commonjs/ui/WidgetProvider.js +6 -0
  20. package/lib/commonjs/ui/WidgetProvider.js.map +1 -1
  21. package/lib/commonjs/ui/components/FileCard.js +134 -0
  22. package/lib/commonjs/ui/components/FileCard.js.map +1 -0
  23. package/lib/commonjs/ui/components/Launcher.js +15 -1
  24. package/lib/commonjs/ui/components/Launcher.js.map +1 -1
  25. package/lib/commonjs/ui/components/VoiceNote.js +354 -0
  26. package/lib/commonjs/ui/components/VoiceNote.js.map +1 -0
  27. package/lib/commonjs/ui/components/icons.js +57 -0
  28. package/lib/commonjs/ui/components/icons.js.map +1 -1
  29. package/lib/commonjs/ui/screens/chat/ChatView.js +33 -14
  30. package/lib/commonjs/ui/screens/chat/ChatView.js.map +1 -1
  31. package/lib/commonjs/ui/screens/chat/ChatView.styles.js +0 -9
  32. package/lib/commonjs/ui/screens/chat/ChatView.styles.js.map +1 -1
  33. package/lib/module/api/client.js +58 -2
  34. package/lib/module/api/client.js.map +1 -1
  35. package/lib/module/audio/voice.js +110 -0
  36. package/lib/module/audio/voice.js.map +1 -0
  37. package/lib/module/i18n.js +6 -0
  38. package/lib/module/i18n.js.map +1 -1
  39. package/lib/module/index.js +2 -1
  40. package/lib/module/index.js.map +1 -1
  41. package/lib/module/locales.js +4 -0
  42. package/lib/module/locales.js.map +1 -1
  43. package/lib/module/push/push-notifications.js +61 -6
  44. package/lib/module/push/push-notifications.js.map +1 -1
  45. package/lib/module/state/use-widget-state.js +30 -1
  46. package/lib/module/state/use-widget-state.js.map +1 -1
  47. package/lib/module/state/widget-store.js +22 -1
  48. package/lib/module/state/widget-store.js.map +1 -1
  49. package/lib/module/ui/WidgetProvider.js +6 -0
  50. package/lib/module/ui/WidgetProvider.js.map +1 -1
  51. package/lib/module/ui/components/FileCard.js +130 -0
  52. package/lib/module/ui/components/FileCard.js.map +1 -0
  53. package/lib/module/ui/components/Launcher.js +16 -2
  54. package/lib/module/ui/components/Launcher.js.map +1 -1
  55. package/lib/module/ui/components/VoiceNote.js +350 -0
  56. package/lib/module/ui/components/VoiceNote.js.map +1 -0
  57. package/lib/module/ui/components/icons.js +55 -0
  58. package/lib/module/ui/components/icons.js.map +1 -1
  59. package/lib/module/ui/screens/chat/ChatView.js +33 -14
  60. package/lib/module/ui/screens/chat/ChatView.js.map +1 -1
  61. package/lib/module/ui/screens/chat/ChatView.styles.js +0 -9
  62. package/lib/module/ui/screens/chat/ChatView.styles.js.map +1 -1
  63. package/lib/typescript/commonjs/api/client.d.ts +14 -0
  64. package/lib/typescript/commonjs/api/client.d.ts.map +1 -1
  65. package/lib/typescript/commonjs/audio/voice.d.ts +29 -0
  66. package/lib/typescript/commonjs/audio/voice.d.ts.map +1 -0
  67. package/lib/typescript/commonjs/i18n.d.ts +4 -0
  68. package/lib/typescript/commonjs/i18n.d.ts.map +1 -1
  69. package/lib/typescript/commonjs/index.d.ts +13 -0
  70. package/lib/typescript/commonjs/index.d.ts.map +1 -1
  71. package/lib/typescript/commonjs/locales.d.ts.map +1 -1
  72. package/lib/typescript/commonjs/push/push-notifications.d.ts +21 -1
  73. package/lib/typescript/commonjs/push/push-notifications.d.ts.map +1 -1
  74. package/lib/typescript/commonjs/state/use-widget-state.d.ts +8 -0
  75. package/lib/typescript/commonjs/state/use-widget-state.d.ts.map +1 -1
  76. package/lib/typescript/commonjs/state/widget-store.d.ts +2 -0
  77. package/lib/typescript/commonjs/state/widget-store.d.ts.map +1 -1
  78. package/lib/typescript/commonjs/ui/WidgetProvider.d.ts.map +1 -1
  79. package/lib/typescript/commonjs/ui/components/FileCard.d.ts +21 -0
  80. package/lib/typescript/commonjs/ui/components/FileCard.d.ts.map +1 -0
  81. package/lib/typescript/commonjs/ui/components/Launcher.d.ts.map +1 -1
  82. package/lib/typescript/commonjs/ui/components/VoiceNote.d.ts +32 -0
  83. package/lib/typescript/commonjs/ui/components/VoiceNote.d.ts.map +1 -0
  84. package/lib/typescript/commonjs/ui/components/icons.d.ts +4 -0
  85. package/lib/typescript/commonjs/ui/components/icons.d.ts.map +1 -1
  86. package/lib/typescript/commonjs/ui/screens/chat/ChatView.d.ts.map +1 -1
  87. package/lib/typescript/commonjs/ui/screens/chat/ChatView.styles.d.ts +0 -9
  88. package/lib/typescript/commonjs/ui/screens/chat/ChatView.styles.d.ts.map +1 -1
  89. package/lib/typescript/commonjs/ui/screens/chat/ChatView.types.d.ts +4 -0
  90. package/lib/typescript/commonjs/ui/screens/chat/ChatView.types.d.ts.map +1 -1
  91. package/lib/typescript/module/api/client.d.ts +14 -0
  92. package/lib/typescript/module/api/client.d.ts.map +1 -1
  93. package/lib/typescript/module/audio/voice.d.ts +29 -0
  94. package/lib/typescript/module/audio/voice.d.ts.map +1 -0
  95. package/lib/typescript/module/i18n.d.ts +4 -0
  96. package/lib/typescript/module/i18n.d.ts.map +1 -1
  97. package/lib/typescript/module/index.d.ts +13 -0
  98. package/lib/typescript/module/index.d.ts.map +1 -1
  99. package/lib/typescript/module/locales.d.ts.map +1 -1
  100. package/lib/typescript/module/push/push-notifications.d.ts +21 -1
  101. package/lib/typescript/module/push/push-notifications.d.ts.map +1 -1
  102. package/lib/typescript/module/state/use-widget-state.d.ts +8 -0
  103. package/lib/typescript/module/state/use-widget-state.d.ts.map +1 -1
  104. package/lib/typescript/module/state/widget-store.d.ts +2 -0
  105. package/lib/typescript/module/state/widget-store.d.ts.map +1 -1
  106. package/lib/typescript/module/ui/WidgetProvider.d.ts.map +1 -1
  107. package/lib/typescript/module/ui/components/FileCard.d.ts +21 -0
  108. package/lib/typescript/module/ui/components/FileCard.d.ts.map +1 -0
  109. package/lib/typescript/module/ui/components/Launcher.d.ts.map +1 -1
  110. package/lib/typescript/module/ui/components/VoiceNote.d.ts +32 -0
  111. package/lib/typescript/module/ui/components/VoiceNote.d.ts.map +1 -0
  112. package/lib/typescript/module/ui/components/icons.d.ts +4 -0
  113. package/lib/typescript/module/ui/components/icons.d.ts.map +1 -1
  114. package/lib/typescript/module/ui/screens/chat/ChatView.d.ts.map +1 -1
  115. package/lib/typescript/module/ui/screens/chat/ChatView.styles.d.ts +0 -9
  116. package/lib/typescript/module/ui/screens/chat/ChatView.styles.d.ts.map +1 -1
  117. package/lib/typescript/module/ui/screens/chat/ChatView.types.d.ts +4 -0
  118. package/lib/typescript/module/ui/screens/chat/ChatView.types.d.ts.map +1 -1
  119. package/package.json +5 -1
  120. package/src/api/client.ts +61 -2
  121. package/src/audio/voice.ts +103 -0
  122. package/src/i18n.ts +6 -0
  123. package/src/index.tsx +13 -0
  124. package/src/locales.ts +4 -0
  125. package/src/push/push-notifications.ts +68 -5
  126. package/src/state/use-widget-state.ts +30 -1
  127. package/src/state/widget-store.ts +22 -1
  128. package/src/ui/WidgetProvider.tsx +6 -0
  129. package/src/ui/components/FileCard.tsx +111 -0
  130. package/src/ui/components/Launcher.tsx +7 -2
  131. package/src/ui/components/VoiceNote.tsx +363 -0
  132. package/src/ui/components/icons.tsx +33 -0
  133. package/src/ui/screens/chat/ChatView.styles.ts +0 -9
  134. package/src/ui/screens/chat/ChatView.tsx +39 -13
  135. package/src/ui/screens/chat/ChatView.types.ts +4 -0
@@ -5,6 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.PushManager = void 0;
7
7
  var _reactNative = require("react-native");
8
+ var _safeUrl = require("../ui/utils/safe-url.js");
8
9
  /**
9
10
  * FCM push notifications — optional.
10
11
  *
@@ -57,6 +58,12 @@ function resolveMessaging() {
57
58
  return null;
58
59
  }
59
60
  }
61
+ const WIDGET_DOCUMENT_TYPES = new Set(['widget_message', 'send_post', 'send_push']);
62
+
63
+ /** A push sent by Workstation for the widget (vs. one of the host app's own). */
64
+ function isWidgetPush(data) {
65
+ return !!data && WIDGET_DOCUMENT_TYPES.has(data.document_type) && typeof data.document_id === 'string' && !!data.document_id;
66
+ }
60
67
  class PushManager {
61
68
  options = {};
62
69
  listenersWired = false;
@@ -69,6 +76,12 @@ class PushManager {
69
76
 
70
77
  /** Registrations still on the wire; unregister() waits for them. */
71
78
  inflight = new Set();
79
+
80
+ /** Taps the host handed over before the session was ready; start() opens them. */
81
+ pendingTaps = [];
82
+
83
+ /** The host and our own listener can both see one tap — open it once. */
84
+ handledMessageIds = new Set();
72
85
  constructor(client, openConversation, openPost = () => {}) {
73
86
  this.client = client;
74
87
  this.openConversation = openConversation;
@@ -87,6 +100,9 @@ class PushManager {
87
100
  */
88
101
  async start() {
89
102
  this.active = true;
103
+ const pending = this.pendingTaps;
104
+ this.pendingTaps = [];
105
+ pending.forEach(message => this.handleTap(message));
90
106
  if (this.manualToken) {
91
107
  await this.register(this.manualToken);
92
108
  }
@@ -153,6 +169,8 @@ class PushManager {
153
169
  */
154
170
  async unregister(authToken) {
155
171
  this.active = false;
172
+ // A tap held for this session must not open in the next user's.
173
+ this.pendingTaps = [];
156
174
  await Promise.all([...this.inflight]);
157
175
  const token = this.lastToken;
158
176
  this.lastToken = null;
@@ -183,26 +201,63 @@ class PushManager {
183
201
  return run;
184
202
  }
185
203
  wireTapHandlers(messaging) {
204
+ // These listeners outlive logout, so taps go through the same session gate
205
+ // as host-forwarded ones: held until start(), and only marked handled then.
186
206
  // Background → tapped: the app was alive, just not in front.
187
207
  messaging.onNotificationOpenedApp(remoteMessage => {
188
- this.handleTap(remoteMessage);
208
+ this.handleNotification(remoteMessage);
189
209
  });
190
210
 
191
211
  // Killed → tapped: the click that launched the app.
192
212
  void messaging.getInitialNotification().then(remoteMessage => {
193
- if (remoteMessage) this.handleTap(remoteMessage);
213
+ if (remoteMessage) this.handleNotification(remoteMessage);
194
214
  }).catch(() => {});
195
215
  }
196
216
 
217
+ /**
218
+ * A tap the host app read itself (`RepzoWidget.handlePushNotification`).
219
+ * Firebase hands out the notification that launched the app only once, so
220
+ * when the host reads it first our own listener gets nothing; the same goes
221
+ * for notifications the host re-posts locally while in the foreground.
222
+ * True when it's a widget push (so the host skips its own routing); it opens
223
+ * now, or once the session is ready.
224
+ */
225
+ handleNotification(message) {
226
+ if (!isWidgetPush(message?.data)) return false;
227
+ if (this.active) this.handleTap(message);else this.pendingTaps.push(message);
228
+ return true;
229
+ }
230
+
197
231
  /**
198
232
  * Only widget pushes are ours — host app notifications pass through. A team
199
- * reply opens its conversation; a Send post opens the post.
233
+ * reply opens its conversation; a Send post opens the post; a Send mobile
234
+ * push reports the open and follows its link, if it has one.
200
235
  */
201
236
  handleTap(remoteMessage) {
202
237
  const data = remoteMessage?.data;
203
- const documentId = data?.document_id;
204
- if (typeof documentId !== 'string' || !documentId) return;
205
- if (data?.document_type === 'widget_message') this.openConversation(documentId);else if (data?.document_type === 'send_post') this.openPost(documentId);
238
+ if (!isWidgetPush(data)) return;
239
+ const messageId = remoteMessage?.messageId;
240
+ if (typeof messageId === 'string' && messageId) {
241
+ if (this.handledMessageIds.has(messageId)) return;
242
+ this.handledMessageIds.add(messageId);
243
+ }
244
+ const documentId = data.document_id;
245
+ if (data?.document_type === 'widget_message') this.openConversation(documentId);else if (data?.document_type === 'send_post') this.openPost(documentId);else if (data?.document_type === 'send_push') this.openSendPush(data);
246
+ }
247
+
248
+ /**
249
+ * The tap already opened the app. A link goes through the same gate as links
250
+ * in messages (`onOpenUrl` first, then web/mail/phone links), so the host can
251
+ * route `myapp://…` itself.
252
+ */
253
+ openSendPush(data) {
254
+ const deliveryId = data.delivery_id;
255
+ if (typeof deliveryId === 'string' && deliveryId) {
256
+ this.client.reportPushOpened(deliveryId).catch(() => {
257
+ // Only the open count misses it; the visitor sees nothing.
258
+ });
259
+ }
260
+ if (typeof data.url === 'string' && data.url) void (0, _safeUrl.openExternalUrl)(data.url);
206
261
  }
207
262
  }
208
263
  exports.PushManager = PushManager;
@@ -1 +1 @@
1
- {"version":3,"names":["_reactNative","require","resolveMessaging","mod","getMessaging","instance","requestPermission","registerDeviceForRemoteMessages","Promise","resolve","getToken","onTokenRefresh","cb","onNotificationOpenedApp","getInitialNotification","factory","default","PushManager","options","listenersWired","lastToken","manualToken","warnedMissingModule","active","inflight","Set","constructor","client","openConversation","openPost","configure","start","register","enabled","messaging","console","warn","wireTapHandlers","token","error","setManualToken","manual","unregister","authToken","all","removePushToken","skipReauth","run","registerPushToken","platform","Platform","OS","bundleId","undefined","then","finally","delete","add","remoteMessage","handleTap","catch","data","documentId","document_id","document_type","exports"],"sourceRoot":"../../../src","sources":["push/push-notifications.ts"],"mappings":";;;;;;AAeA,IAAAA,YAAA,GAAAC,OAAA;AAfA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AA2BA;;AAUA,SAASC,gBAAgBA,CAAA,EAA2B;EAClD,IAAI;IACF,MAAMC,GAAG,GAAGF,OAAO,CAAC,kCAAkC,CAAC;;IAEvD;IACA;IACA,IAAI,OAAOE,GAAG,EAAEC,YAAY,KAAK,UAAU,EAAE;MAC3C,MAAMC,QAAQ,GAAGF,GAAG,CAACC,YAAY,CAAC,CAAC;MACnC,OAAO;QACLE,iBAAiB,EAA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,CAAE6C,aAAkB,IAAK;MACxD,IAAI,CAACC,SAAS,CAACD,aAAa,CAAC;IAC/B,CAAC,CAAC;;IAEF;IACA,KAAKxB,SAAS,CACXpB,sBAAsB,CAAC,CAAC,CACxBwC,IAAI,CAAEI,aAAkB,IAAK;MAC5B,IAAIA,aAAa,EAAE,IAAI,CAACC,SAAS,CAACD,aAAa,CAAC;IAClD,CAAC,CAAC,CACDE,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC;EACpB;;EAEA;AACF;AACA;AACA;EACUD,SAASA,CAACD,aAAkB,EAAE;IACpC,MAAMG,IAAI,GAAGH,aAAa,EAAEG,IAAI;IAChC,MAAMC,UAAU,GAAGD,IAAI,EAAEE,WAAW;IACpC,IAAI,OAAOD,UAAU,KAAK,QAAQ,IAAI,CAACA,UAAU,EAAE;IACnD,IAAID,IAAI,EAAEG,aAAa,KAAK,gBAAgB,EAAE,IAAI,CAACpC,gBAAgB,CAACkC,UAAU,CAAC,CAAC,KAC3E,IAAID,IAAI,EAAEG,aAAa,KAAK,WAAW,EAAE,IAAI,CAACnC,QAAQ,CAACiC,UAAU,CAAC;EACzE;AACF;AAACG,OAAA,CAAAhD,WAAA,GAAAA,WAAA","ignoreList":[]}
1
+ {"version":3,"names":["_reactNative","require","_safeUrl","resolveMessaging","mod","getMessaging","instance","requestPermission","registerDeviceForRemoteMessages","Promise","resolve","getToken","onTokenRefresh","cb","onNotificationOpenedApp","getInitialNotification","factory","default","WIDGET_DOCUMENT_TYPES","Set","isWidgetPush","data","has","document_type","document_id","PushManager","options","listenersWired","lastToken","manualToken","warnedMissingModule","active","inflight","pendingTaps","handledMessageIds","constructor","client","openConversation","openPost","configure","start","pending","forEach","message","handleTap","register","enabled","messaging","console","warn","wireTapHandlers","token","error","setManualToken","manual","unregister","authToken","all","removePushToken","skipReauth","run","registerPushToken","platform","Platform","OS","bundleId","undefined","then","finally","delete","add","remoteMessage","handleNotification","catch","push","messageId","documentId","openSendPush","deliveryId","delivery_id","reportPushOpened","url","openExternalUrl","exports"],"sourceRoot":"../../../src","sources":["push/push-notifications.ts"],"mappings":";;;;;;AAeA,IAAAA,YAAA,GAAAC,OAAA;AAEA,IAAAC,QAAA,GAAAD,OAAA;AAjBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AA4BA;;AAUA,SAASE,gBAAgBA,CAAA,EAA2B;EAClD,IAAI;IACF,MAAMC,GAAG,GAAGH,OAAO,CAAC,kCAAkC,CAAC;;IAEvD;IACA;IACA,IAAI,OAAOG,GAAG,EAAEC,YAAY,KAAK,UAAU,EAAE;MAC3C,MAAMC,QAAQ,GAAGF,GAAG,CAACC,YAAY,CAAC,CAAC;MACnC,OAAO;QACLE,iBAAiB,EAAEA,CAAA,KAAMH,GAAG,CAACG,iBAAiB,CAACD,QAAQ,CAAC;QACxDE,+BAA+B,EAAEA,CAAA,KAC/B,OAAOJ,GAAG,CAACI,+BAA+B,KAAK,UAAU,GACrDJ,GAAG,CAACI,+BAA+B,CAACF,QAAQ,CAAC,GAC7CG,OAAO,CAACC,OAAO,CAAC,CAAC;QACvBC,QAAQ,EAAEA,CAAA,KAAMP,GAAG,CAACO,QAAQ,CAACL,QAAQ,CAAC;QACtCM,cAAc,EAAGC,EAAE,IAAKT,GAAG,CAACQ,cAAc,CAACN,QAAQ,EAAEO,EAAE,CAAC;QACxDC,uBAAuB,EAAGD,EAAE,IAAKT,GAAG,CAACU,uBAAuB,CAACR,QAAQ,EAAEO,EAAE,CAAC;QAC1EE,sBAAsB,EAAEA,CAAA,KAAMX,GAAG,CAACW,sBAAsB,CAACT,QAAQ;MACnE,CAAC;IACH;;IAEA;IACA,MAAMU,OAAO,GAAGZ,GAAG,EAAEa,OAAO,IAAIb,GAAG;IACnC,IAAI,OAAOY,OAAO,KAAK,UAAU,EAAE,OAAO,IAAI;IAC9C,MAAMV,QAAQ,GAAGU,OAAO,CAAC,CAAC;IAC1B,IAAI,CAACV,QAAQ,EAAE,OA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AEA;AACF;AACA;AACA;AACA;EACUwD,YAAYA,CAACxD,IAA6B,EAAE;IAClD,MAAMyD,UAAU,GAAGzD,IAAI,CAAC0D,WAAW;IACnC,IAAI,OAAOD,UAAU,KAAK,QAAQ,IAAIA,UAAU,EAAE;MAChD,IAAI,CAAC1C,MAAM,CAAC4C,gBAAgB,CAACF,UAAU,CAAC,CAACL,KAAK,CAAC,MAAM;QACnD;MAAA,CACD,CAAC;IACJ;IACA,IAAI,OAAOpD,IAAI,CAAC4D,GAAG,KAAK,QAAQ,IAAI5D,IAAI,CAAC4D,GAAG,EAAE,KAAK,IAAAC,wBAAe,EAAC7D,IAAI,CAAC4D,GAAG,CAAC;EAC9E;AACF;AAACE,OAAA,CAAA1D,WAAA,GAAAA,WAAA","ignoreList":[]}
@@ -3,6 +3,8 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
+ exports.shallowEqual = shallowEqual;
7
+ exports.useWidgetSelector = useWidgetSelector;
6
8
  exports.useWidgetState = useWidgetState;
7
9
  exports.useWidgetStore = useWidgetStore;
8
10
  var _react = require("react");
@@ -20,4 +22,33 @@ function useWidgetState() {
20
22
  function useWidgetStore() {
21
23
  return _controller.controller.store;
22
24
  }
25
+
26
+ /**
27
+ * A slice of the state that re-renders only when the slice changes (by
28
+ * `isEqual`) — for UI that lives on the host's own screens, like the launcher,
29
+ * which shouldn't redraw on every message or typing event. Internal.
30
+ */
31
+ function useWidgetSelector(select, isEqual) {
32
+ const store = _controller.controller.store;
33
+ const last = (0, _react.useRef)(null);
34
+ const getSnapshot = () => {
35
+ const state = store.getState();
36
+ const previous = last.current;
37
+ if (previous && previous.state === state) return previous.value;
38
+ const value = select(state);
39
+ // Same slice from a newer state: keep the old value so React bails out.
40
+ last.current = {
41
+ state,
42
+ value: previous && isEqual(previous.value, value) ? previous.value : value
43
+ };
44
+ return last.current.value;
45
+ };
46
+ return (0, _react.useSyncExternalStore)(store.subscribe, getSnapshot, getSnapshot);
47
+ }
48
+
49
+ /** Same keys, same values (by identity). */
50
+ function shallowEqual(previous, next) {
51
+ const keys = Object.keys(previous);
52
+ return keys.length === Object.keys(next).length && keys.every(key => Object.is(previous[key], next[key]));
53
+ }
23
54
  //# sourceMappingURL=use-widget-state.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_react","require","_controller","useWidgetState","store","controller","useSyncExternalStore","subscribe","getState","useWidgetStore"],"sourceRoot":"../../../src","sources":["state/use-widget-state.ts"],"mappings":";;;;;;;AAMA,IAAAA,MAAA,GAAAC,OAAA;AAEA,IAAAC,WAAA,GAAAD,OAAA;AARA;AACA;AACA;AACA;AACA;;AAQO,SAASE,cAAcA,CAAA,EAAgB;EAC5C,MAAMC,KAAK,GAAGC,sBAAU,CAACD,KAAK;EAC9B,OAAO,IAAAE,2BAAoB,EAACF,KAAK,CAACG,SAAS,EAAEH,KAAK,CAACI,QAAQ,EAAEJ,KAAK,CAACI,QAAQ,CAAC;AAC9E;AAEO,SAASC,cAAcA,CAAA,EAAgB;EAC5C,OAAOJ,sBAAU,CAACD,KAAK;AACzB","ignoreList":[]}
1
+ {"version":3,"names":["_react","require","_controller","useWidgetState","store","controller","useSyncExternalStore","subscribe","getState","useWidgetStore","useWidgetSelector","select","isEqual","last","useRef","getSnapshot","state","previous","current","value","shallowEqual","next","keys","Object","length","every","key","is"],"sourceRoot":"../../../src","sources":["state/use-widget-state.ts"],"mappings":";;;;;;;;;AAMA,IAAAA,MAAA,GAAAC,OAAA;AAEA,IAAAC,WAAA,GAAAD,OAAA;AARA;AACA;AACA;AACA;AACA;;AAQO,SAASE,cAAcA,CAAA,EAAgB;EAC5C,MAAMC,KAAK,GAAGC,sBAAU,CAACD,KAAK;EAC9B,OAAO,IAAAE,2BAAoB,EAACF,KAAK,CAACG,SAAS,EAAEH,KAAK,CAACI,QAAQ,EAAEJ,KAAK,CAACI,QAAQ,CAAC;AAC9E;AAEO,SAASC,cAAcA,CAAA,EAAgB;EAC5C,OAAOJ,sBAAU,C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url.js");
25
25
  */
26
26
 
27
27
  /** Sent on every init; must match `package.json` (tests/version.test.js checks). */
28
- const SDK_VERSION = '@repzo/widget-react-native@1.2.0';
28
+ const SDK_VERSION = '@repzo/widget-react-native@1.2.2';
29
29
 
30
30
  /** The platform this session reports — mobile sessions get the Mobile SDKs overrides. */
31
31
  function sessionPlatform() {
@@ -46,6 +46,13 @@ const LOGOUT_REQUEST_TIMEOUT_MS = 5_000;
46
46
  const STREAM_REAUTH_MIN_INTERVAL_MS = 30_000;
47
47
  /** Live replies in the open thread advance the server read cursor, batched. */
48
48
  const MARK_READ_DEBOUNCE_MS = 1_000;
49
+ /**
50
+ * Back from the background sooner than this, availability and the post are
51
+ * still current enough to skip re-asking. Reps hop to maps or the camera and
52
+ * back all day; the list and the open thread still catch up every time, since
53
+ * the stream was closed meanwhile.
54
+ */
55
+ const FOREGROUND_REFRESH_AFTER_MS = 5 * 60_000;
49
56
  /** Live events held back while a draft's first send is creating its thread. */
50
57
  const DRAFT_EVENT_BUFFER_LIMIT = 50;
51
58
  /** How long a post stays up after a reaction, thanking them, before it goes. */
@@ -165,6 +172,9 @@ class WidgetStore {
165
172
  userKeyLoaded = false;
166
173
  pendingConversationId = null;
167
174
  appStateSubscription = null;
175
+
176
+ /** When the app last went to the background (0: hasn't this session). */
177
+ backgroundedAt = 0;
168
178
  lastTypingPingAt = 0;
169
179
  visitorTypingActive = false;
170
180
  seenMessageIds = [];
@@ -842,10 +852,14 @@ class WidgetStore {
842
852
  }
843
853
  watchAppState() {
844
854
  if (this.appStateSubscription) return;
855
+ // Booted while already in the background (a push woke the app): coming
856
+ // to the foreground is a return from the background too.
857
+ if (_reactNative.AppState.currentState === 'background') this.backgroundedAt = Date.now();
845
858
  this.appStateSubscription = _reactNative.AppState.addEventListener('change', status => {
846
859
  if (status === 'active') {
847
860
  void this.resumeFromBackground();
848
861
  } else if (status === 'background') {
862
+ this.backgroundedAt = Date.now();
849
863
  this.realtime.close();
850
864
  }
851
865
  });
@@ -858,6 +872,12 @@ class WidgetStore {
858
872
  if (this.state.error) await this.retry();
859
873
  return;
860
874
  }
875
+ // Only the background closes the stream. Back from merely inactive (a
876
+ // system sheet, Face ID, the notification shade) it never stopped, so
877
+ // there is nothing to catch up on.
878
+ if (!this.backgroundedAt) return;
879
+ const awayMs = Date.now() - this.backgroundedAt;
880
+ this.backgroundedAt = 0;
861
881
  const epoch = this.epoch;
862
882
  const token = await this.client.getToken();
863
883
  if (!token || this.isStale(epoch)) return;
@@ -865,6 +885,7 @@ class WidgetStore {
865
885
  // The stream had a gap: refresh the list so unread/snippets are correct,
866
886
  // and the thread on screen so replies sent meanwhile show up.
867
887
  await Promise.all([this.refreshConversations(), this.refreshOpenThread()]);
888
+ if (awayMs < FOREGROUND_REFRESH_AFTER_MS) return;
868
889
  await this.refreshConfig();
869
890
  // A post may have gone live (or ended) while the app was away.
870
891
  if (!this.isStale(epoch)) this.loadPost();