Skip to content

Commit 57104ee

Browse files
committed
fix: optimization dashboard render
1 parent 06f4865 commit 57104ee

4 files changed

Lines changed: 17 additions & 9 deletions

File tree

src/frontend/platform/src/contexts/locationContext.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ export function LocationProvider({ children }: { children: ReactNode }) {
101101
// Only update the benchMenu property
102102
setAppConfig(prev => ({
103103
...prev,
104-
benchMenu: bench?.menuShow || false
104+
benchMenu: bench?.menuShow ?? true
105105
}));
106106
})
107107
.catch(error => {

src/frontend/platform/src/pages/Dashboard/hook.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,15 @@ export const usePublishDashboard = () => {
2525
published ? DashboardStatus.Draft : DashboardStatus.Published
2626
),
2727
onSuccess: (_, variables) => {
28-
queryClient.invalidateQueries({ queryKey: [DashboardQueryKey, variables.id] });
29-
queryClient.setQueryData([DashboardsQueryKey], (old) => {
28+
const newStatus = variables.published ? DashboardStatus.Draft : DashboardStatus.Published
29+
queryClient.setQueryData([DashboardQueryKey, variables.id], (old: any) => {
30+
old.status = newStatus // Reduce render
31+
return old
32+
})
33+
queryClient.setQueryData([DashboardsQueryKey], (old: any) => {
3034
return old.map(el => el.id === variables.id ? {
3135
...el,
32-
status: variables.published ? DashboardStatus.Draft : DashboardStatus.Published
36+
status: newStatus
3337
} : el);
3438
});
3539
toast({

src/frontend/platform/src/pages/Dashboard/index.tsx

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,16 @@ export default function DashboardPage() {
3737
queryFn: getDashboards,
3838
})
3939

40-
const updateMutation = useMutation({
40+
const updateTitlteMutation = useMutation({
4141
mutationFn: ({ id, title }: { id: string; title: string }) => updateDashboardTitle(id, title),
4242
onSuccess: (a, { id, title }) => {
4343
// queryClient.invalidateQueries({ queryKey: [DashboardsQueryKey] })
44-
queryClient.invalidateQueries({ queryKey: [DashboardQueryKey, id] })
45-
queryClient.setQueryData([DashboardsQueryKey], (old) =>
44+
// queryClient.invalidateQueries({ queryKey: [DashboardQueryKey, id] })
45+
queryClient.setQueryData([DashboardQueryKey, id], (old: any) => {
46+
old.title = title
47+
return old
48+
})
49+
queryClient.setQueryData([DashboardsQueryKey], (old: any) =>
4650
old.map(el => el.id === id ? { ...el, title } : el));
4751
toast({
4852
description: t('renameSuccess'),
@@ -70,7 +74,7 @@ export default function DashboardPage() {
7074
})
7175

7276
const handleRename = (id: string, newTitle: string) => {
73-
updateMutation.mutate({ id, title: newTitle })
77+
updateTitlteMutation.mutate({ id, title: newTitle })
7478
}
7579

7680
const handleShare = async (id: string) => {

src/frontend/platform/src/pages/LoginPage/login.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ export const LoginPage = () => {
7575
localStorage.removeItem('LOGIN_PATHNAME')
7676
location.href = pathname
7777
} else {
78-
const path = import.meta.env.DEV ? '/admin' : '/workspace'
78+
const path = import.meta.env.DEV ? '/admin' : '/workspace/'
7979
const rootUrl = `${location.origin}${__APP_ENV__.BASE_URL}${path}`
8080
location.href = `${__APP_ENV__.BASE_URL}${location.pathname}` === '/' ? rootUrl : location.href
8181
}

0 commit comments

Comments
 (0)