From fa9d756a485b2fb1207f947b7f6eea46c279310c Mon Sep 17 00:00:00 2001 From: Artem Panchuk Date: Mon, 16 Dec 2024 15:48:07 +0300 Subject: [PATCH] feat(DashKit): add updated reloadItems method --- src/components/DashKit/DashKit.tsx | 4 ++++ src/components/GridLayout/GridLayout.js | 9 +++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/components/DashKit/DashKit.tsx b/src/components/DashKit/DashKit.tsx index 4818018..28d7b3d 100644 --- a/src/components/DashKit/DashKit.tsx +++ b/src/components/DashKit/DashKit.tsx @@ -222,4 +222,8 @@ export class DashKit extends React.PureComponent { getItemsMeta() { return this.metaRef.current?.getItemsMeta(); } + + reloadItems(targetIds?: string[]) { + this.metaRef.current?.reloadItems(targetIds); + } } diff --git a/src/components/GridLayout/GridLayout.js b/src/components/GridLayout/GridLayout.js index 6c65d8f..58c0552 100644 --- a/src/components/GridLayout/GridLayout.js +++ b/src/components/GridLayout/GridLayout.js @@ -204,15 +204,20 @@ export default class GridLayout extends React.PureComponent { }); } - reloadItems() { + reloadItems(targetIds) { const { editMode, settings: {autoupdateInterval, silentLoading} = {}, reloadItems, } = this.context; + const {isPageHidden} = this.state; const autoupdateIntervalMs = Number(autoupdateInterval) * 1000; - if (autoupdateIntervalMs) { + + if (targetIds) { + const targetPluginRefs = this.pluginsRefs.filter((ref) => targetIds.includes(ref.id)); + reloadItems(targetPluginRefs, {silentLoading, noVeil: true, targetIds}); + } else if (autoupdateIntervalMs) { const timeSinceLastReload = new Date().getTime() - (this._lastReloadAt || 0); const reloadIntervalRemains = autoupdateIntervalMs - timeSinceLastReload;