Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add notification of new content #7

Merged
merged 1 commit into from
Sep 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,30 @@ import {watchEffect} from 'vue';
import {storeToRefs} from 'pinia';
import {useI18n} from 'vue-i18n';
import {RouterView, useRoute} from 'vue-router';
import {useRegisterSW} from 'virtual:pwa-register/vue';
import {useActivityStore} from '@/stores/activityStore';
import {useAppStateStore} from '@/stores/appStateStore';
import NavBar from '@/components/NavBar.vue';
import ToastContainer from '@/components/ToastContainer.vue';

const {addToastMessage} = useAppStateStore();

const {t, locale} = useI18n();

const route = useRoute();

const {allVeggies} = storeToRefs(useActivityStore());
const {settings} = storeToRefs(useAppStateStore());

const {updateServiceWorker} = useRegisterSW({
immediate: true,
async onNeedRefresh() {
addToastMessage(t('general.updateReady'));
await updateServiceWorker();
window.location.reload();
},
});

watchEffect(() => {
locale.value = settings.value.locale;
});
Expand Down
3 changes: 2 additions & 1 deletion src/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,8 @@
"clickToAdd": "Add {0}",
"clickToRemove": "Remove {0}",
"close": "Close",
"start": "Start"
"start": "Start",
"updateReady": "The app has been updated with latest content."
},
"home": {
"info": "Learn more",
Expand Down
3 changes: 2 additions & 1 deletion src/i18n/fi.json
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,8 @@
"clickToAdd": "Lisää {0}",
"clickToRemove": "Poista {0}",
"close": "Sulje",
"start": "Aloita"
"start": "Aloita",
"updateReady": "Sovellus on päivitetty uuteen versioon."
},
"home": {
"info": "Lue lisää",
Expand Down