diff --git a/resources/js/Components/UpdateSidebarNotification.vue b/resources/js/Components/UpdateSidebarNotification.vue new file mode 100644 index 00000000..e968ff21 --- /dev/null +++ b/resources/js/Components/UpdateSidebarNotification.vue @@ -0,0 +1,46 @@ + + + + + diff --git a/resources/js/Layouts/AppLayout.vue b/resources/js/Layouts/AppLayout.vue index 23064f8d..ca3427b2 100644 --- a/resources/js/Layouts/AppLayout.vue +++ b/resources/js/Layouts/AppLayout.vue @@ -33,24 +33,33 @@ import { isBillingActivated } from '@/utils/billing'; import type { User } from '@/types/models'; import { ArrowsRightLeftIcon } from '@heroicons/vue/16/solid'; import { fetchToken, isTokenValid } from '@/utils/session'; +import UpdateSidebarNotification from '@/Components/UpdateSidebarNotification.vue'; defineProps({ title: String, }); const showSidebarMenu = ref(false); - +const isUnloading = ref(false); onMounted(async () => { // make sure that the initial requests are only loaded once, this can be removed once we move away from inertia if (window.initialDataLoaded !== true) { window.initialDataLoaded = true; initializeStores(); } + window.onbeforeunload = () => { + isUnloading.value = true; + }; window.onfocus = async () => { if (!isTokenValid()) { await fetchToken(); } - refreshStores(); + setTimeout(() => { + // prevent store refreshing on navigation + if (isUnloading.value === false) { + refreshStores(); + } + }, 100); }; }); @@ -178,16 +187,19 @@ const page = usePage<{ - +