@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.
@@ -1989,7 +1989,6 @@ class ConversationConnector {
1989
1989
  _ConversationConnector_connectionListeners.set(this, []);
1990
1990
  }
1991
1991
  connect(url, channelName, channelTopic, accessToken) {
1992
- var _a;
1993
1992
  return __awaiter(this, void 0, void 0, function* () {
1994
1993
  this.url = url;
1995
1994
  this.accessToken = accessToken;
@@ -1999,12 +1998,22 @@ class ConversationConnector {
1999
1998
  url: splittedUrl,
2000
1999
  params
2001
2000
  } = split_url_params(this.url);
2002
- if (!((_a = this.socket) === null || _a === void 0 ? void 0 : _a.isConnected())) {
2001
+ if (!this.socket) {
2003
2002
  this.socket = new Socket(splittedUrl, {
2004
2003
  params: Object.assign(Object.assign({}, params), {
2005
2004
  v: apiVersion
2006
- })
2005
+ }),
2006
+ reconnectAfterMs: tries => {
2007
+ // Calculate the backoff time based on the number of tries.
2008
+ const backoff = Math.pow(2, tries) * 250;
2009
+ // Limit the backoff time to 10 seconds.
2010
+ return Math.min(backoff, 10000);
2011
+ }
2007
2012
  });
2013
+ }
2014
+ // Checks if the socket is not already connected before attempting a connection.
2015
+ // This prevents multiple connection attempts during server reconnects, network switches or SPA route changes.
2016
+ if (!this.socket.isConnected()) {
2008
2017
  this.socket.connect();
2009
2018
  }
2010
2019
  this.channel = this.socket.channel(this.channelTopic, {
@@ -2622,7 +2631,7 @@ _API_ready = new WeakMap(), _API_externalId = new WeakMap(), _API_conversationAu
2622
2631
  return {
2623
2632
  clientName: "@seamly/web-ui",
2624
2633
  clientVariant: api_classPrivateFieldGet(this, _API_layoutMode, "f"),
2625
- clientVersion: "22.3.2",
2634
+ clientVersion: "22.3.4",
2626
2635
  currentUrl: window.location.toString(),
2627
2636
  screenResolution: `${window.screen.width}x${window.screen.height}`,
2628
2637
  timezone: getTimeZone(),
@@ -17918,7 +17927,7 @@ const useNotification = () => {
17918
17927
  const [visibilityState, setVisibilityState] = (0,hooks_.useState)(document.visibilityState);
17919
17928
  const showNotifications = useSelector_useSelector(selectShowNotifications);
17920
17929
  const requestPermission = (0,hooks_.useCallback)(() => use_notifications_awaiter(void 0, void 0, void 0, function* () {
17921
- if (Notification && permission !== 'granted') {
17930
+ if (hasNotificationSupport && permission !== 'granted') {
17922
17931
  const notificationPermission = yield Notification.requestPermission();
17923
17932
  setPermission(notificationPermission);
17924
17933
  }