Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(DashKit): add updated reloadItems method #230

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/components/DashKit/DashKit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@
defaultProps: defaultGridProps,
groups: groups.reduce<Record<string, GridReflowOptions>>((memo, g) => {
const groupId = g.id || DEFAULT_GROUP;
memo[groupId] = g.gridProperties

Check warning on line 93 in src/components/DashKit/DashKit.tsx

View workflow job for this annotation

GitHub Actions / Verify Files

Assignment to property of function parameter 'memo'
? getReflowProps(g.gridProperties(defaultGridProps))
: defaultGridProps;

Expand Down Expand Up @@ -222,4 +222,8 @@
getItemsMeta() {
return this.metaRef.current?.getItemsMeta();
}

reloadItems(targetIds?: string[]) {
this.metaRef.current?.reloadItems(targetIds);
}
}
9 changes: 7 additions & 2 deletions src/components/GridLayout/GridLayout.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
Loading