@@ -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,11 +43,50 @@ 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
50+ let watchInterval = null
51+
4952onMounted (async () => {
53+ /**
54+ * Watch for package.json->version and notify users about the new version
55+ */
56+ appStore .version = (await $fetch (" /api/version" )).version
57+ if (! import .meta.dev)
58+ watchInterval = watchForUpdate (appStore .version , (newVersion ) => {
59+ clearInterval (watchInterval)
60+ notificationsStore .create ({
61+ notification: {
62+ type: " success" ,
63+ icon: " info" ,
64+ title: " New update is available" ,
65+ description: " Refresh the page to get the latest update with new features & bug fixes." ,
66+ autoDestroy: false ,
67+ irremovable: true ,
68+ actions: [
69+ {
70+ name: " Refresh" ,
71+ icon: " refresh" ,
72+ callback : () => {
73+ location .reload ()
74+ },
75+ },
76+ {
77+ name: " Changelog" ,
78+ icon: " menu" ,
79+ callback : () => {
80+ window
81+ .open (` https://github.com/celenium-io/celenium-interface/releases/tag/v${ newVersion} ` , " _blank" )
82+ .focus ()
83+ },
84+ },
85+ ],
86+ },
87+ })
88+ })
89+
5090 if (localStorage .bookmarks ) {
5191 bookmarksStore .bookmarks = JSON .parse (localStorage .bookmarks )
5292 }
@@ -56,7 +96,7 @@ onMounted(async () => {
5696 }
5797
5898 settingsStore .init ()
59- rollupsRankingStore .init ()
99+ activityStore .init ()
60100
61101 const runtimeConfig = useRuntimeConfig ()
62102 amp .init (runtimeConfig .public .AMP )
@@ -117,6 +157,10 @@ onMounted(async () => {
117157 Socket .close ()
118158 }
119159})
160+
161+ onBeforeUnmount (() => {
162+ clearInterval (watchInterval)
163+ })
120164< / script>
121165
122166< template>
@@ -127,9 +171,9 @@ onMounted(async () => {
127171 < NuxtPage / >
128172
129173 < div id= " tooltip" / >
130- <div id =" modal" />
131174 < div id= " dropdown" / >
132175 < div id= " popover" / >
176+ < div id= " modal" / >
133177
134178 < ModalsManager / >
135179 < Notifications / >
0 commit comments