From 44074ff1a3f765c9b955d72ed6a999b1e4754615 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joaqu=C3=ADn=20S=C3=A1nchez?= Date: Wed, 25 Sep 2024 17:55:32 +0200 Subject: [PATCH] fix: change page reload and account switch logic (#2975) --- components/nav/NavSide.vue | 29 ++++++- composables/idb/index.ts | 73 ++++++++-------- composables/users.ts | 62 ++++--------- pages/[[server]]/lists.vue | 137 +---------------------------- pages/[[server]]/lists/index.vue | 144 +++++++++++++++++++++++++++++++ pages/hashtags.vue | 11 +-- pages/hashtags/index.vue | 20 +++++ plugins/0.setup-users.ts | 83 +++++++++++++++++- plugins/masto.ts | 22 ----- 9 files changed, 328 insertions(+), 253 deletions(-) create mode 100644 pages/[[server]]/lists/index.vue create mode 100644 pages/hashtags/index.vue delete mode 100644 plugins/masto.ts diff --git a/components/nav/NavSide.vue b/components/nav/NavSide.vue index bc051519..6b1318dd 100644 --- a/components/nav/NavSide.vue +++ b/components/nav/NavSide.vue @@ -8,6 +8,31 @@ const { notifications } = useNotifications() const useStarFavoriteIcon = usePreferences('useStarFavoriteIcon') const lastAccessedNotificationRoute = useLocalStorage(STORAGE_KEY_LAST_ACCESSED_NOTIFICATION_ROUTE, '') const lastAccessedExploreRoute = useLocalStorage(STORAGE_KEY_LAST_ACCESSED_EXPLORE_ROUTE, '') + +const notificationsLink = computed(() => { + const hydrated = isHydrated.value + const user = currentUser.value + const lastRoute = lastAccessedNotificationRoute.value + if (!hydrated || !user || !lastRoute) { + return '/notifications' + } + + return `/notifications/${lastRoute}` +}) +const exploreLink = computed(() => { + const hydrated = isHydrated.value + const server = currentServer.value + let lastRoute = lastAccessedExploreRoute.value + if (!hydrated) { + return '/explore' + } + + if (lastRoute.length) { + lastRoute = `/${lastRoute}` + } + + return server ? `/${server}/explore${lastRoute}` : `/explore${lastRoute}` +})