@@ -5,6 +5,7 @@ import * as Sentry from "@sentry/vue"
55/** Services */
66import Socket from " @/services/api/socket"
77import amp from " @/services/amp"
8+ import { watchForUpdate } from " @/services/version"
89
910/** Components */
1011import ModalsManager from " @/components/modals/ModalsManager.vue"
@@ -16,22 +17,22 @@ import { fetchHead } from "@/services/api/main"
1617import { fetchLatestBlocks } from " @/services/api/block"
1718
1819/** Store */
19- import { useNodeStore } from " @/store/node"
20- import { useAppStore } from " @/store/app"
21- import { useBookmarksStore } from " @/store/bookmarks"
22- import { useSettingsStore } from " @/store/settings"
23- import { useEnumStore } from " @/store/enums"
24- import { useLegalStore } from " @/store/legal"
25- import { useNotificationsStore } from " @/store/notifications"
26- import { useRollupsRankingStore } from " @/store/rollupsrank "
20+ import { useNodeStore } from " @/store/node.store "
21+ import { useAppStore } from " @/store/app.store "
22+ import { useBookmarksStore } from " @/store/bookmarks.store "
23+ import { useSettingsStore } from " @/store/settings.store "
24+ import { useEnumStore } from " @/store/enums.store "
25+ import { useLegalStore } from " @/store/legal.store "
26+ import { useNotificationsStore } from " @/store/notifications.store "
27+ import { useActivityStore } from " @/store/activity.store "
2728const nodeStore = useNodeStore ()
2829const appStore = useAppStore ()
2930const bookmarksStore = useBookmarksStore ()
3031const settingsStore = useSettingsStore ()
3132const enumStore = useEnumStore ()
3233const legalStore = useLegalStore ()
3334const notificationsStore = useNotificationsStore ()
34- const rollupsRankingStore = useRollupsRankingStore ()
35+ const activityStore = useActivityStore ()
3536
3637bookmarksStore .$subscribe ((mutation , state ) => {
3738 localStorage .setItem (" bookmarks" , JSON .stringify (state .bookmarks ))
@@ -42,13 +43,52 @@ settingsStore.$subscribe((mutation, state) => {
4243legalStore .$subscribe ((mutation , state ) => {
4344 localStorage .setItem (" legal" , JSON .stringify (state .legal ))
4445})
45- rollupsRankingStore .$subscribe ((mutation , state ) => {
46+ activityStore .$subscribe ((mutation , state ) => {
4647 localStorage .setItem (" rollups_ranking" , JSON .stringify (state .rollups_ranking ))
4748})
4849
4950appStore .initConstants ()
5051
52+ let watchInterval = null
53+
5154onMounted (async () => {
55+ /**
56+ * Watch for package.json->version and notify users about the new version
57+ */
58+ appStore .version = (await $fetch (" /api/version" )).version
59+ if (! import .meta.dev)
60+ watchInterval = watchForUpdate (appStore .version , (newVersion ) => {
61+ clearInterval (watchInterval)
62+ notificationsStore .create ({
63+ notification: {
64+ type: " success" ,
65+ icon: " info" ,
66+ title: " New update is available" ,
67+ description: " Refresh the page to get the latest update with new features & bug fixes." ,
68+ autoDestroy: false ,
69+ irremovable: true ,
70+ actions: [
71+ {
72+ name: " Refresh" ,
73+ icon: " refresh" ,
74+ callback : () => {
75+ location .reload ()
76+ },
77+ },
78+ {
79+ name: " Changelog" ,
80+ icon: " menu" ,
81+ callback : () => {
82+ window
83+ .open (` https://github.com/celenium-io/celenium-interface/releases/tag/v${ newVersion} ` , " _blank" )
84+ .focus ()
85+ },
86+ },
87+ ],
88+ },
89+ })
90+ })
91+
5292 if (localStorage .bookmarks ) {
5393 bookmarksStore .bookmarks = JSON .parse (localStorage .bookmarks )
5494 }
@@ -58,7 +98,7 @@ onMounted(async () => {
5898 }
5999
60100 settingsStore .init ()
61- rollupsRankingStore .init ()
101+ activityStore .init ()
62102
63103 const runtimeConfig = useRuntimeConfig ()
64104 amp .init (runtimeConfig .public .AMP )
@@ -119,6 +159,10 @@ onMounted(async () => {
119159 Socket .close ()
120160 }
121161})
162+
163+ onBeforeUnmount (() => {
164+ clearInterval (watchInterval)
165+ })
122166< / script>
123167
124168< template>
0 commit comments