Skip to content

Commit

Permalink
Merge branch 'master' of github.com:Netflix/metaflow-ui
Browse files Browse the repository at this point in the history
  • Loading branch information
obgibson committed Apr 25, 2024
2 parents 6edc266 + 5cc5124 commit 3bc22b1
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
5 changes: 5 additions & 0 deletions src/components/MFCard/DynamicCardIframe.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -89,12 +89,17 @@ const DynamicCardIframe: React.FC<Props> = ({ task, hash }) => {
const handleIframeLoad = (iframe: HTMLIFrameElement) => {
const token = iframe?.contentWindow?.METAFLOW_RELOAD_TOKEN;
const updateFn = iframe?.contentWindow?.metaflow_card_update;
const needsReload = iframe?.contentWindow?.needsReload;
cacheTimestampRef.current = -1;
// If the card supplies a reload token and an update function, start the refresh loop
if (updateFn && token) {
timeoutRef.current = setTimeout(() => {
getNewData(token, updateFn, iframe);
}, DYNAMIC_CARDS_REFRESH_INTERVAL);
} else if (needsReload) {
timeoutRef.current = setTimeout(() => {
iframe?.contentWindow?.location?.reload();
}, DYNAMIC_CARDS_REFRESH_INTERVAL);
}

return () => {
Expand Down
3 changes: 2 additions & 1 deletion src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ declare global {
MF_DEFAULT_TIME_FILTER_DAYS: string;
METAFLOW_RELOAD_TOKEN: string;
metaflow_card_update: (payload: object) => void;
needsReload: boolean;
}
}
/**
Expand Down Expand Up @@ -58,4 +59,4 @@ export const DEFAULT_TIME_FILTER_DAYS: number =
export const DYNAMIC_CARDS_REFRESH_INTERVAL =
process.env.REACT_APP_DYNAMIC_CARDS_REFRESH_INTERVAL !== undefined
? Number(process.env.REACT_APP_DYNAMIC_CARDS_REFRESH_INTERVAL)
: 400;
: 1000;

0 comments on commit 3bc22b1

Please sign in to comment.