@copart/ops-tool-kit 1.8.1-alpha.27 → 1.8.1-alpha.28

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.
@@ -33,7 +33,7 @@ var ReactDOM__namespace = /*#__PURE__*/_interopNamespace(ReactDOM);
33
33
  var ReactDOM__default = /*#__PURE__*/_interopDefaultLegacy(ReactDOM);
34
34
 
35
35
  const name$f = "@copart/ops-tool-kit";
36
- const version$5 = "1.8.1-alpha.27";
36
+ const version$5 = "1.8.1-alpha.28";
37
37
  const main$1 = "dist/ops-tool-kit.js";
38
38
  const style = "dist/ops-tool-kit.css";
39
39
  const files = [
@@ -39837,7 +39837,7 @@ function fetchG2Notifications(updateNotifications, updateAllNotificationsList) {
39837
39837
  });
39838
39838
  }
39839
39839
 
39840
- function startWebSocketConnection(updateNotifications, updateAllNotificationsList) {
39840
+ function startWebSocketConnection(updateNotifications, updateAllNotificationsList, reConnectSocket) {
39841
39841
  var _storage$getSessionIt, _storage$getSessionIt2;
39842
39842
 
39843
39843
  var coreAppConfig = storage$1.getLocalItem('opsportal-core:config');
@@ -39857,7 +39857,13 @@ function startWebSocketConnection(updateNotifications, updateAllNotificationsLis
39857
39857
 
39858
39858
  client.onopen = function () {
39859
39859
  console.log('WebSocket connection has been opened');
39860
- };
39860
+ }; // setInterval(()=>{
39861
+ // client.send('_ping_')
39862
+ // },5000)
39863
+ // setInterval(()=>{
39864
+ // console.log('ready state=',client.readyState)
39865
+ // },1000)
39866
+
39861
39867
 
39862
39868
  client.onmessage = function (message) {
39863
39869
  var notification = [];
@@ -39880,6 +39886,7 @@ function startWebSocketConnection(updateNotifications, updateAllNotificationsLis
39880
39886
 
39881
39887
  client.onclose = function () {
39882
39888
  console.log('Socket connection Closed');
39889
+ reConnectSocket();
39883
39890
  };
39884
39891
 
39885
39892
  return client;
@@ -48029,6 +48036,29 @@ var AppBar = function AppBar(_ref) {
48029
48036
  };
48030
48037
 
48031
48038
  var selectedYard = (_storage$getSessionIt = storage$1.getSessionItem('dashboard')) === null || _storage$getSessionIt === void 0 ? void 0 : _storage$getSessionIt.selectedYard;
48039
+
48040
+ var reConnectSocket = function reConnectSocket() {
48041
+ socketClient && socketClient.close();
48042
+ setSocketClient(startWebSocketConnection(updateNotifications, updateAllNotificationsList, reConnectSocket));
48043
+ };
48044
+
48045
+ var handleVisibilityChange = function handleVisibilityChange() {
48046
+ if (document.visibilityState === 'visible') {
48047
+ if (socketClient && socketClient.readyState !== WebSocket.OPEN) {
48048
+ reConnectSocket();
48049
+ }
48050
+ }
48051
+ };
48052
+
48053
+ React.useEffect(function () {
48054
+ if (socketClient) {
48055
+ document.addEventListener('visibilitychange', handleVisibilityChange);
48056
+ }
48057
+
48058
+ return function () {
48059
+ document.removeEventListener('visibilitychange', handleVisibilityChange);
48060
+ };
48061
+ }, [socketClient]);
48032
48062
  React.useEffect(function () {
48033
48063
  setNotifications([]);
48034
48064
  setListOfAllNotifications([]);
@@ -48047,7 +48077,7 @@ var AppBar = function AppBar(_ref) {
48047
48077
  if (history.location.pathname !== '/logout' && history.location.pathname !== '/login' && localStorage.getItem('login') && tileConfigAccess) {
48048
48078
  if (notificationsSource.includes('Nchan')) {
48049
48079
  fetchG2Notifications(updateNotifications, updateAllNotificationsList);
48050
- setSocketClient(startWebSocketConnection(updateNotifications, updateAllNotificationsList));
48080
+ setSocketClient(startWebSocketConnection(updateNotifications, updateAllNotificationsList, reConnectSocket));
48051
48081
  }
48052
48082
 
48053
48083
  if (!firebaseInitialized && notificationsSource.includes('Firebase')) {