@seamly/web-ui 22.3.2 → 22.3.4

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.
@@ -11522,7 +11522,6 @@ class ConversationConnector {
11522
11522
  _ConversationConnector_connectionListeners.set(this, []);
11523
11523
  }
11524
11524
  connect(url, channelName, channelTopic, accessToken) {
11525
- var _a;
11526
11525
  return __awaiter(this, void 0, void 0, function* () {
11527
11526
  this.url = url;
11528
11527
  this.accessToken = accessToken;
@@ -11532,12 +11531,22 @@ class ConversationConnector {
11532
11531
  url: splittedUrl,
11533
11532
  params
11534
11533
  } = split_url_params(this.url);
11535
- if (!((_a = this.socket) === null || _a === void 0 ? void 0 : _a.isConnected())) {
11534
+ if (!this.socket) {
11536
11535
  this.socket = new Socket(splittedUrl, {
11537
11536
  params: Object.assign(Object.assign({}, params), {
11538
11537
  v: javascripts_config/* apiVersion */.tW
11539
- })
11538
+ }),
11539
+ reconnectAfterMs: tries => {
11540
+ // Calculate the backoff time based on the number of tries.
11541
+ const backoff = Math.pow(2, tries) * 250;
11542
+ // Limit the backoff time to 10 seconds.
11543
+ return Math.min(backoff, 10000);
11544
+ }
11540
11545
  });
11546
+ }
11547
+ // Checks if the socket is not already connected before attempting a connection.
11548
+ // This prevents multiple connection attempts during server reconnects, network switches or SPA route changes.
11549
+ if (!this.socket.isConnected()) {
11541
11550
  this.socket.connect();
11542
11551
  }
11543
11552
  this.channel = this.socket.channel(this.channelTopic, {
@@ -12155,7 +12164,7 @@ _API_ready = new WeakMap(), _API_externalId = new WeakMap(), _API_conversationAu
12155
12164
  return {
12156
12165
  clientName: "@seamly/web-ui",
12157
12166
  clientVariant: api_classPrivateFieldGet(this, _API_layoutMode, "f"),
12158
- clientVersion: "22.3.2",
12167
+ clientVersion: "22.3.4",
12159
12168
  currentUrl: window.location.toString(),
12160
12169
  screenResolution: `${window.screen.width}x${window.screen.height}`,
12161
12170
  timezone: getTimeZone(),
@@ -19204,7 +19213,7 @@ const useNotification = () => {
19204
19213
  const [visibilityState, setVisibilityState] = (0,hooks_.useState)(document.visibilityState);
19205
19214
  const showNotifications = (0,es/* useSelector */.v9)(selectShowNotifications);
19206
19215
  const requestPermission = (0,hooks_.useCallback)(() => use_notifications_awaiter(void 0, void 0, void 0, function* () {
19207
- if (Notification && permission !== 'granted') {
19216
+ if (hasNotificationSupport && permission !== 'granted') {
19208
19217
  const notificationPermission = yield Notification.requestPermission();
19209
19218
  setPermission(notificationPermission);
19210
19219
  }