@gravity-ui/dashkit 3.2.0 → 3.3.0
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/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [3.3.0](https://github.com/gravity-ui/dashkit/compare/v3.2.0...v3.3.0) (2022-11-10)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Features
|
|
7
|
+
|
|
8
|
+
* improve autoupdate reload logic ([#25](https://github.com/gravity-ui/dashkit/issues/25)) ([3060d92](https://github.com/gravity-ui/dashkit/commit/3060d921407d02f136d58ea1cbd3c272d9f3def7))
|
|
9
|
+
|
|
3
10
|
## [3.2.0](https://github.com/gravity-ui/dashkit/compare/v3.1.0...v3.2.0) (2022-10-27)
|
|
4
11
|
|
|
5
12
|
|
|
@@ -10,6 +10,7 @@ export default class GridLayout extends React.PureComponent<any, any, any> {
|
|
|
10
10
|
componentDidUpdate(): void;
|
|
11
11
|
componentWillUnmount(): void;
|
|
12
12
|
_timeout: any;
|
|
13
|
+
_lastReloadAt: any;
|
|
13
14
|
onVisibilityChange: () => void;
|
|
14
15
|
adjustWidgetLayout: ({ widgetId, needSetDefault, adjustedWidgetLayout }: {
|
|
15
16
|
widgetId: any;
|
|
@@ -60,16 +60,15 @@ class GridLayout extends react_1.default.PureComponent {
|
|
|
60
60
|
reloadItems() {
|
|
61
61
|
const { editMode, settings: { autoupdateInterval, silentLoading } = {}, reloadItems, } = this.context;
|
|
62
62
|
const { isPageHidden } = this.state;
|
|
63
|
-
const
|
|
64
|
-
if (
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
}, autoupdateIntervalNumber * 1000);
|
|
63
|
+
const autoupdateIntervalMs = Number(autoupdateInterval) * 1000;
|
|
64
|
+
if (autoupdateIntervalMs) {
|
|
65
|
+
const timeSinceLastReload = new Date().getTime() - (this._lastReloadAt || 0);
|
|
66
|
+
const reloadIntervalRemains = autoupdateIntervalMs - timeSinceLastReload;
|
|
67
|
+
if (!isPageHidden && !editMode && reloadIntervalRemains <= 0) {
|
|
68
|
+
this._lastReloadAt = new Date().getTime();
|
|
69
|
+
reloadItems(this.pluginsRefs, { silentLoading, noVeil: true });
|
|
70
|
+
}
|
|
71
|
+
this._timeout = setTimeout(() => this.reloadItems(), reloadIntervalRemains <= 0 ? autoupdateIntervalMs : reloadIntervalRemains);
|
|
73
72
|
}
|
|
74
73
|
}
|
|
75
74
|
render() {
|
|
@@ -10,6 +10,7 @@ export default class GridLayout extends React.PureComponent<any, any, any> {
|
|
|
10
10
|
componentDidUpdate(): void;
|
|
11
11
|
componentWillUnmount(): void;
|
|
12
12
|
_timeout: any;
|
|
13
|
+
_lastReloadAt: any;
|
|
13
14
|
onVisibilityChange: () => void;
|
|
14
15
|
adjustWidgetLayout: ({ widgetId, needSetDefault, adjustedWidgetLayout }: {
|
|
15
16
|
widgetId: any;
|
|
@@ -57,16 +57,15 @@ export default class GridLayout extends React.PureComponent {
|
|
|
57
57
|
reloadItems() {
|
|
58
58
|
const { editMode, settings: { autoupdateInterval, silentLoading } = {}, reloadItems, } = this.context;
|
|
59
59
|
const { isPageHidden } = this.state;
|
|
60
|
-
const
|
|
61
|
-
if (
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
}, autoupdateIntervalNumber * 1000);
|
|
60
|
+
const autoupdateIntervalMs = Number(autoupdateInterval) * 1000;
|
|
61
|
+
if (autoupdateIntervalMs) {
|
|
62
|
+
const timeSinceLastReload = new Date().getTime() - (this._lastReloadAt || 0);
|
|
63
|
+
const reloadIntervalRemains = autoupdateIntervalMs - timeSinceLastReload;
|
|
64
|
+
if (!isPageHidden && !editMode && reloadIntervalRemains <= 0) {
|
|
65
|
+
this._lastReloadAt = new Date().getTime();
|
|
66
|
+
reloadItems(this.pluginsRefs, { silentLoading, noVeil: true });
|
|
67
|
+
}
|
|
68
|
+
this._timeout = setTimeout(() => this.reloadItems(), reloadIntervalRemains <= 0 ? autoupdateIntervalMs : reloadIntervalRemains);
|
|
70
69
|
}
|
|
71
70
|
}
|
|
72
71
|
render() {
|