Skip to content

Database governance built for humans and agents — controlling changes and access across every major database.

fix(frontend): avoid calling ListProjects too many times (#6174)

Liu Jie2f74a8f85f7
diff --git a/frontend/src/components/ProvideDashboardContext.vue b/frontend/src/components/ProvideDashboardContext.vue
index 909a3ea79f..c10cfdee29 100644
--- a/frontend/src/components/ProvideDashboardContext.vue
+++ b/frontend/src/components/ProvideDashboardContext.vue
@@ -11,6 +11,7 @@ import {
useLegacyProjectStore,
useDebugStore,
useUserStore,
+ useProjectV1Store,
} from "@/store";
import { DEFAULT_PROJECT_ID } from "../types";
import { useSettingV1Store } from "@/store/modules/v1/setting";
@@ -23,6 +24,7 @@ export default defineComponent({
useRoleStore().fetchRoleList(),
useUserStore().fetchUserList(),
useEnvironmentV1Store().fetchEnvironments(),
+ useProjectV1Store().fetchProjectList(true),
// The default project hosts databases not explicitly assigned to other users project.
useLegacyProjectStore().fetchProjectById(DEFAULT_PROJECT_ID),
useLegacyProjectStore().fetchAllProjectList(), // TODO(Jim): For legacy API support only. Remove this after refactored
diff --git a/frontend/src/store/modules/v1/project.ts b/frontend/src/store/modules/v1/project.ts
index 7863d12845..7c8fdb2643 100644
--- a/frontend/src/store/modules/v1/project.ts
+++ b/frontend/src/store/modules/v1/project.ts
@@ -153,10 +153,17 @@ export const useProjectV1Store = defineStore("project_v1", () => {
};
});
-export const useProjectV1List = (showDeleted: MaybeRef<boolean> = false) => {
+export const useProjectV1List = (
+ showDeleted: MaybeRef<boolean> = false,
+ forceUpdate = false
+) => {
const store = useProjectV1Store();
const ready = ref(false);
watchEffect(() => {
+ if (!unref(forceUpdate)) {
+ ready.value = true;
+ return;
+ }
ready.value = false;
store.fetchProjectList(unref(showDeleted)).then(() => {
ready.value = true;