From 86b535d751b428ea55089b36d8e1e8add96a0c19 Mon Sep 17 00:00:00 2001 From: Kristaps Fabians Geikins Date: Thu, 18 Jan 2024 11:00:48 +0200 Subject: [PATCH] chore(fe2): project page load speed optimization (#1974) * merging queries for faster load * preload plugin * latest threads/models query optimization --- .../components/header/NavUserMenu.vue | 7 ++- .../project/models-page/Results.vue | 2 + .../project/page/latest-items/Comments.vue | 14 +++--- .../project/page/latest-items/Models.vue | 19 +++++--- .../components/project/page/models/Card.vue | 20 ++++---- .../project/page/models/CardView.vue | 12 +++-- .../project/page/models/ListView.vue | 18 +++---- .../projects/ProjectDashboardCard.vue | 2 + .../components/user/profile/EditDialog.vue | 7 +-- .../resources/add-model/DialogModelTab.vue | 1 + .../lib/auth/composables/activeUser.ts | 3 ++ .../lib/common/composables/graphql.ts | 15 ++++++ .../lib/common/generated/gql/gql.ts | 9 +--- .../lib/common/generated/gql/graphql.ts | 10 +--- .../frontend-2/lib/core/composables/server.ts | 4 +- .../frontend-2/lib/core/configs/apollo.ts | 7 ++- .../frontend-2/lib/core/graphql/queries.ts | 9 ---- .../frontend-2/pages/projects/[id]/index.vue | 19 ++++---- .../plugins/002-healthMetrics.server.ts | 8 ++++ .../frontend-2/plugins/003-dataPreload.ts | 48 +++++++++++++++++++ 20 files changed, 154 insertions(+), 80 deletions(-) delete mode 100644 packages/frontend-2/lib/core/graphql/queries.ts create mode 100644 packages/frontend-2/plugins/003-dataPreload.ts diff --git a/packages/frontend-2/components/header/NavUserMenu.vue b/packages/frontend-2/components/header/NavUserMenu.vue index c99ea3c862..3c0f61aa5c 100644 --- a/packages/frontend-2/components/header/NavUserMenu.vue +++ b/packages/frontend-2/components/header/NavUserMenu.vue @@ -142,19 +142,18 @@ import { CloudArrowDownIcon, ChatBubbleLeftRightIcon } from '@heroicons/vue/24/outline' -import { useQuery } from '@vue/apollo-composable' import { Roles } from '@speckle/shared' import type { Optional } from '@speckle/shared' import { useActiveUser } from '~~/lib/auth/composables/activeUser' import { useAuthManager } from '~~/lib/auth/composables/auth' import { loginRoute } from '~~/lib/common/helpers/route' import { useTheme, AppTheme } from '~~/lib/core/composables/theme' -import { serverVersionInfoQuery } from '~~/lib/core/graphql/queries' +import { useServerInfo } from '~/lib/core/composables/server' const { logout } = useAuthManager() const { activeUser, isGuest } = useActiveUser() const { isDarkTheme, setTheme } = useTheme() -const { result } = useQuery(serverVersionInfoQuery) +const { serverInfo } = useServerInfo() const route = useRoute() const router = useRouter() @@ -163,7 +162,7 @@ const showProfileEditDialog = ref(false) const token = computed(() => route.query.token as Optional) const Icon = computed(() => (isDarkTheme.value ? SunIcon : MoonIcon)) -const version = computed(() => result.value?.serverInfo.version) +const version = computed(() => serverInfo.value?.version) const isAdmin = computed(() => activeUser.value?.role === Roles.Server.Admin) diff --git a/packages/frontend-2/components/project/models-page/Results.vue b/packages/frontend-2/components/project/models-page/Results.vue index 5814bb8ad7..5c99a1e240 100644 --- a/packages/frontend-2/components/project/models-page/Results.vue +++ b/packages/frontend-2/components/project/models-page/Results.vue @@ -5,6 +5,7 @@ v-if="gridOrList === GridListToggleValue.List" :search="finalSearch" :project="project" + :project-id="project.id" :source-apps="sourceApps" :contributors="contributors" @update:loading="finalLoading = $event" @@ -14,6 +15,7 @@ v-if="gridOrList === GridListToggleValue.Grid" :search="finalSearch" :project="project" + :project-id="project.id" :source-apps="sourceApps" :contributors="contributors" @update:loading="finalLoading = $event" diff --git a/packages/frontend-2/components/project/page/latest-items/Comments.vue b/packages/frontend-2/components/project/page/latest-items/Comments.vue index 67429aa55a..057bfc9eff 100644 --- a/packages/frontend-2/components/project/page/latest-items/Comments.vue +++ b/packages/frontend-2/components/project/page/latest-items/Comments.vue @@ -1,8 +1,8 @@