Skip to content

Commit

Permalink
Merge pull request #834 from jlandowner/event-watch3
Browse files Browse the repository at this point in the history
  • Loading branch information
oruharo authored Jun 6, 2024
2 parents 9f8359c + e80e168 commit 976bc72
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
16 changes: 7 additions & 9 deletions web/dashboard-ui/src/views/organisms/WorkspaceModule.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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<User>(loginUser || new User());
const [users, setUsers] = useState<User[]>([loginUser || new User()]);

Expand All @@ -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[]) => {
Expand All @@ -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;
Expand Down Expand Up @@ -153,7 +152,6 @@ const useWorkspace = () => {
} catch (error) {
handleError(error);
} finally {
updateClock();
releaseMask();
}
};
Expand Down
2 changes: 2 additions & 0 deletions web/dashboard-ui/src/views/pages/WorkspacePage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 },
Expand Down Expand Up @@ -596,6 +597,7 @@ const WorkspaceList: React.VFC = () => {
color="inherit"
onClick={() => {
stopAllPolling();
enqueueSnackbar("Stop all polling", { variant: "info" });
}}
onMouseLeave={() => setIsHoverRefreshIcon(false)}
>
Expand Down

0 comments on commit 976bc72

Please sign in to comment.