From 0c6aecace682376a9552a3cd26fb1a4ef3857f08 Mon Sep 17 00:00:00 2001 From: Hironsan Date: Fri, 9 Jun 2023 13:40:04 +0900 Subject: [PATCH] Remove fetching projects --- frontend/middleware/setCurrentProject.ts | 8 +++--- .../pages/projects/_id/comments/index.vue | 8 +++--- .../projects/_id/dataset/_example_id/edit.vue | 7 +++--- frontend/pages/projects/_id/dataset/index.vue | 10 ++++---- .../projects/_id/labels/_label_id/edit.vue | 7 +++--- frontend/pages/projects/_id/labels/add.vue | 7 +++--- frontend/pages/projects/_id/labels/import.vue | 8 +++--- frontend/pages/projects/_id/labels/index.vue | 25 +++++++++---------- frontend/pages/projects/_id/metrics/index.vue | 5 ++-- 9 files changed, 40 insertions(+), 45 deletions(-) diff --git a/frontend/middleware/setCurrentProject.ts b/frontend/middleware/setCurrentProject.ts index b015050f..b32975cc 100644 --- a/frontend/middleware/setCurrentProject.ts +++ b/frontend/middleware/setCurrentProject.ts @@ -1,13 +1,13 @@ import { NuxtAppOptions } from '@nuxt/types' +import _ from 'lodash' -export default async ({ app, route, redirect }: NuxtAppOptions) => { +export default _.debounce(async ({ app, route, redirect }: NuxtAppOptions) => { const project = app.store.getters['projects/currentProject'] - const isNotSet = Object.keys(project).length === 0 && project.constructor === Object - if (isNotSet || project.id !== route.params.id) { + if (project.id !== route.params.id) { try { await app.store.dispatch('projects/setCurrentProject', route.params.id) } catch (e) { redirect('/projects') } } -} +}, 1000) diff --git a/frontend/pages/projects/_id/comments/index.vue b/frontend/pages/projects/_id/comments/index.vue index 89225e6e..2acd2d47 100644 --- a/frontend/pages/projects/_id/comments/index.vue +++ b/frontend/pages/projects/_id/comments/index.vue @@ -26,12 +26,12 @@