From 15fef6f0b45d79bd3cb57a81d8cea572d1222346 Mon Sep 17 00:00:00 2001 From: kadiryazici Date: Wed, 28 Feb 2024 19:21:37 +0300 Subject: [PATCH] Move route to seperate composable --- src/App.vue | 10 +++++----- src/components/AppScroller.vue | 6 +++--- src/components/AppSidebar.vue | 6 +++--- src/{stores/route.ts => composables/useRoute.ts} | 3 ++- src/main.ts | 2 +- src/pages/HomePage.vue | 4 ++-- src/pages/LandingPage.vue | 2 +- src/pages/SettingsPage.vue | 2 +- src/stores/store.ts | 2 +- 9 files changed, 19 insertions(+), 18 deletions(-) rename src/{stores/route.ts => composables/useRoute.ts} (89%) diff --git a/src/App.vue b/src/App.vue index 7c3d46e..b0a0ca5 100644 --- a/src/App.vue +++ b/src/App.vue @@ -9,13 +9,13 @@ import { useStore } from './stores/store' import LandingPage from './pages/LandingPage.vue' import { useInterval } from './composables/useInterval' import { AppStorage } from './storage' -import { Page, useRoute } from './stores/route' import ContextMenu from './components/ContextMenu.vue' import { useContextmenu } from './stores/contextmenu' import { useTheme } from './composables/useTheme' +import { Page, useRoute } from './composables/useRoute' const store = useStore() -const route = useRoute() +const { currentPage } = useRoute() const contextmenu = useContextmenu() useInterval(() => { @@ -41,9 +41,9 @@ watchEffect(() => { - - - + + + >(null) @@ -18,11 +18,11 @@ const focus = batchFn(() => { scrollView.value?.getElement()?.focus() }) -watch(() => route.currentPage, focus, { flush: 'post' }) useTauriEvent('window:hidden', focus) onMounted(focus) +watch(route.currentPage, () => { + focus() -watch(() => route.currentPage, () => { const element = scrollView.value?.osInstance()?.elements().scrollOffsetElement if (element) element.scrollTop = 0 diff --git a/src/components/AppSidebar.vue b/src/components/AppSidebar.vue index f215646..ae4634a 100644 --- a/src/components/AppSidebar.vue +++ b/src/components/AppSidebar.vue @@ -6,8 +6,8 @@ import { REPO_LINK } from '../constants' import { useStore } from '../stores/store' import { AppStorage } from '../storage' import { useKey } from '../composables/useKey' -import { Page, useRoute } from '../stores/route' import { useI18n } from '../composables/useI18n' +import { Page, useRoute } from '../composables/useRoute' import { Icons } from './Icons' import SidebarButton from './SidebarButton.vue' import Popover from './Popover.vue' @@ -49,7 +49,7 @@ const moreItems = computed(() => [ useKey('r', () => { store.fetchNotifications(true) -}, { source: () => route.currentPage === Page.Home }) +}, { source: () => route.currentPage.value === Page.Home })