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 })
@@ -109,7 +109,7 @@ useKey('r', () => {
diff --git a/src/stores/route.ts b/src/composables/useRoute.ts
similarity index 89%
rename from src/stores/route.ts
rename to src/composables/useRoute.ts
index 5d0a270..40c788d 100644
--- a/src/stores/route.ts
+++ b/src/composables/useRoute.ts
@@ -1,6 +1,7 @@
import { readonly, ref, shallowRef } from 'vue'
import { defineStore } from 'pinia'
import type { Option } from '../types'
+import { singleton } from '../utils/common'
export enum Page {
Settings = 'Settings',
@@ -12,7 +13,7 @@ export type PageState = {
fetchOnEnter?: boolean
}
-export const useRoute = defineStore('route', () => {
+export const useRoute = singleton(() => {
const currentPage = ref(Page.Landing)
const pageFrom = ref