Explorar o código

fix: reset data according to version

nian hai 1 mes
pai
achega
fc52c9fa20
Modificáronse 2 ficheiros con 20 adicións e 19 borrados
  1. 18 0
      src/helpers/resetSystemData.ts
  2. 2 19
      src/main.ts

+ 18 - 0
src/helpers/resetSystemData.ts

@@ -0,0 +1,18 @@
+import { DEFAULT_PREFERENCES_OPTIONS, usePreferencesStore } from '@/stores/preferences'
+import { useTabsStore } from '@/stores/tabs'
+import { useUserStore } from '@/stores/user'
+import { haveSameKeys } from '@/utils/lodash-helpers'
+
+export function resetSystemData() {
+  const preferencesStore = usePreferencesStore()
+  const tabsStore = useTabsStore()
+  const userStore = useUserStore()
+
+  const oldLocalStorage = localStorage.getItem('configure')
+  if (oldLocalStorage || haveSameKeys(preferencesStore.preferences, DEFAULT_PREFERENCES_OPTIONS)) {
+    tabsStore.clearTabs()
+    preferencesStore.reset()
+    userStore.cleanup()
+    localStorage.clear()
+  }
+}

+ 2 - 19
src/main.ts

@@ -4,25 +4,8 @@ import { createPinia } from 'pinia'
 import { createApp } from 'vue'
 
 import App from './App.vue'
+import { resetSystemData } from './helpers/resetSystemData'
 import router from './router'
-import { DEFAULT_PREFERENCES_OPTIONS, usePreferencesStore } from './stores/preferences'
-import { useTabsStore } from './stores/tabs'
-import { useUserStore } from './stores/user'
-import { haveSameKeys } from './utils/lodash-helpers'
-
-function clearSystemData() {
-  const preferencesStore = usePreferencesStore()
-  const tabsStore = useTabsStore()
-  const userStore = useUserStore()
-
-  const oldLocalStorage = localStorage.getItem('configure')
-  if (oldLocalStorage || haveSameKeys(preferencesStore.preferences, DEFAULT_PREFERENCES_OPTIONS)) {
-    tabsStore.clearTabs()
-    preferencesStore.reset()
-    userStore.cleanup()
-    localStorage.clear()
-  }
-}
 
 async function setupApp() {
   const app = createApp(App)
@@ -30,7 +13,7 @@ async function setupApp() {
   app.use(createPinia())
   app.use(router)
 
-  clearSystemData()
+  resetSystemData()
 
   await router.isReady()