diff --git a/web/dashboard-ui/src/views/organisms/WorkspaceModule.tsx b/web/dashboard-ui/src/views/organisms/WorkspaceModule.tsx index b4011c74..c91198f2 100644 --- a/web/dashboard-ui/src/views/organisms/WorkspaceModule.tsx +++ b/web/dashboard-ui/src/views/organisms/WorkspaceModule.tsx @@ -70,13 +70,11 @@ const useWorkspace = () => { const [workspaces, setWorkspaces] = useState< { [key: string]: WorkspaceWrapper } >({}); - // order - // const wss = result.items.sort((a, b) => (a.name < b.name) ? -1 : 1); const { handleError } = useHandleError(); const workspaceService = useWorkspaceService(); const userService = useUserService(); - const { loginUser, myEvents, updateClock } = useLogin(); + const { loginUser, updateClock } = useLogin(); const [user, setUser] = useState(loginUser || new User()); const [users, setUsers] = useState([loginUser || new User()]); @@ -90,11 +88,11 @@ const useWorkspace = () => { Object.keys(workspaces).forEach((name) => { clearTimer(name); }); - enqueueSnackbar("Stop all polling", { variant: "info" }); }; useEffect(() => { - getWorkspaces(); + stopAllPolling(); + getWorkspaces(user.name); }, [user]); const upsertWorkspace = (ws: Workspace, events?: Event[]) => { @@ -104,20 +102,21 @@ const useWorkspace = () => { if (events) pws.events = events; return { ...prev, [ws.name]: pws }; }); + updateClock(); }; /** * WorkspaceList: workspace list */ - const getWorkspaces = async (userName?: string) => { + const getWorkspaces = async (userName: string) => { console.log("getWorkspaces", userName); setMask(); try { const getWorkspacesResult = await workspaceService.getWorkspaces({ - userName: userName || user.name, + userName: userName, }); const getEventsResult = await userService.getEvents({ - userName: userName || user.name, + userName: userName, }); const workspaces = getWorkspacesResult.items; @@ -153,7 +152,6 @@ const useWorkspace = () => { } catch (error) { handleError(error); } finally { - updateClock(); releaseMask(); } }; diff --git a/web/dashboard-ui/src/views/pages/WorkspacePage.tsx b/web/dashboard-ui/src/views/pages/WorkspacePage.tsx index fc9ac7b4..44c9da01 100644 --- a/web/dashboard-ui/src/views/pages/WorkspacePage.tsx +++ b/web/dashboard-ui/src/views/pages/WorkspacePage.tsx @@ -528,6 +528,7 @@ const WorkspaceList: React.VFC = () => { stopAllPolling, } = useWorkspaceModule(); const { loginUser } = useLogin(); + const { enqueueSnackbar } = useSnackbar(); const isPriv = hasPrivilegedRole(loginUser?.roles || []); const [urlParam, setUrlParam] = useUrlState({ "search": "" }, { stringifyOptions: { skipEmptyString: true }, @@ -596,6 +597,7 @@ const WorkspaceList: React.VFC = () => { color="inherit" onClick={() => { stopAllPolling(); + enqueueSnackbar("Stop all polling", { variant: "info" }); }} onMouseLeave={() => setIsHoverRefreshIcon(false)} >