@evergis/react 3.1.93 → 3.1.94

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.
package/dist/react.esm.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { jsx, jsxs, Fragment as Fragment$1 } from 'react/jsx-runtime';
2
2
  import { IconButton, Flex, transition, Chip, Icon, Description, FlexSpan, IconToggle, Popup, Menu, DraggableTree, shadows, Divider, LegendToggler, Tooltip as Tooltip$1, DropdownField, MultiSelectContainer, IconButtonButton, FlatButton, DraggableTreeContainer, Dialog, DialogTitle, ThemeProvider, darkTheme, DialogContent, CircularProgress, LinearProgress, H2, defaultTheme, Preview, Dropdown, Blank, Popover, UploaderItemArea, UploaderTitleWrapper, Uploader, NumberRangeSlider, useAsyncAutocomplete, AutoComplete, Checkbox, RangeNumberInput, dateFormat } from '@evergis/uilib-gl';
3
- import { createContext, memo, useRef, useState, useEffect, useCallback, useContext, useMemo, Fragment } from 'react';
3
+ import { createContext, memo, useRef, useState, useCallback, useEffect, useContext, useMemo, Fragment } from 'react';
4
4
  import styled, { createGlobalStyle, css, useTheme } from 'styled-components';
5
5
  import { lineChartClassNames, BarChart as BarChart$1, barChartClassNames, LineChart, PieChart } from '@evergis/charts';
6
6
  import { AttributeType, generateId, GeometryType, RemoteTaskStatus } from '@evergis/api';
@@ -3935,6 +3935,15 @@ const ServerNotificationsContext = createContext({});
3935
3935
  const useServerNotifications = (url, initialized) => {
3936
3936
  const hubConnection = useRef(null);
3937
3937
  const [connection, setConnection] = useState(null);
3938
+ const subscribeNotifications = useCallback(() => {
3939
+ if (!connection || connection.state !== "Connected") {
3940
+ return;
3941
+ }
3942
+ connection
3943
+ .invoke("SubscribeNotifications", [])
3944
+ .then(() => console.info("Подписка `SubscribeNotifications` оформлена"))
3945
+ .catch(err => console.info("Ошибка подписки `SubscribeNotifications`:", err));
3946
+ }, [connection]);
3938
3947
  useEffect(() => {
3939
3948
  if (!initialized) {
3940
3949
  return;
@@ -3943,6 +3952,7 @@ const useServerNotifications = (url, initialized) => {
3943
3952
  .withUrl(`${url}?clientId=${generateId()}`, {
3944
3953
  withCredentials: true,
3945
3954
  })
3955
+ .withAutomaticReconnect({ nextRetryDelayInMilliseconds: () => 3000 })
3946
3956
  .configureLogging(LogLevel.Information)
3947
3957
  .build();
3948
3958
  hubConnection.current
@@ -3955,10 +3965,9 @@ const useServerNotifications = (url, initialized) => {
3955
3965
  if (!connection || connection.state !== "Connected") {
3956
3966
  return;
3957
3967
  }
3958
- connection
3959
- .invoke("SubscribeNotifications", [])
3960
- .then(() => console.info("Подписка `SubscribeNotifications` оформлена"))
3961
- .catch(err => console.info("Ошибка подписки `SubscribeNotifications`:", err));
3968
+ connection.onreconnecting(() => console.info("Переподключение к серверным нотификациям"));
3969
+ connection.onreconnected(subscribeNotifications);
3970
+ subscribeNotifications();
3962
3971
  }, [connection]);
3963
3972
  return connection;
3964
3973
  };