-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #232 from ymaheshwari1/app-update
Implemented: component to add support to let user know after new app release and update the app
- Loading branch information
Showing
8 changed files
with
129 additions
and
23 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<template> | ||
<div class="section-header"> | ||
<div> | ||
<h1>{{ translate('App') }}</h1> | ||
<p class="overline">{{ translate("Version: ", { appVersion }) }}</p> | ||
</div> | ||
<div class="ion-text-end"> | ||
<p class="overline">{{ translate("Built: ", { builtDateTime: getDateTime(appInfo.builtTime) }) }}</p> | ||
<ion-button v-if="pwaState.updateExists" @click="refreshApp()" fill="outline" color="dark" size="small">{{ translate("Update") }}</ion-button> | ||
</div> | ||
</div> | ||
</template> | ||
|
||
<script setup lang="ts"> | ||
import { IonButton } from '@ionic/vue'; | ||
import { DateTime } from 'luxon'; | ||
import { appContext, translate } from 'src'; | ||
import { computed } from 'vue'; | ||
declare var process: any; | ||
const appState = appContext.config.globalProperties.$store | ||
const pwaState = computed(() => appState.getters['user/getPwaState']) | ||
const refreshApp = () => { | ||
appState.dispatch('user/updatePwaState', { registration: pwaState.value.registration, updateExists: false }); | ||
if (!pwaState.value.registration || !pwaState.value.registration.waiting) return | ||
pwaState.value.registration.waiting.postMessage({ type: 'SKIP_WAITING' }) | ||
} | ||
const appInfo = (process.env.VUE_APP_VERSION_INFO ? JSON.parse(process.env.VUE_APP_VERSION_INFO) : {}) as any; | ||
const appVersion = appInfo.branch ? (appInfo.branch + "-" + appInfo.revision) : appInfo.tag; | ||
const getDateTime = (time: any) => DateTime.fromMillis(time).toLocaleString(DateTime.DATETIME_MED); | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import { register } from 'register-service-worker' | ||
|
||
declare var process: any; | ||
|
||
if (process.env.NODE_ENV === 'production') { | ||
register(`${process.env.BASE_URL}service-worker.js`, { | ||
ready () { | ||
console.log( | ||
'App is being served from cache by a service worker.\n' + | ||
'For more details, visit https://goo.gl/AFskqB' | ||
) | ||
}, | ||
registered (registration: any) { | ||
console.log('Service worker has been registered.') | ||
setInterval(() => { | ||
registration.update(); | ||
}, 1000 * 60 * 60); // check for service worker update hourly | ||
}, | ||
cached () { | ||
console.log('Content has been cached for offline use.') | ||
}, | ||
updatefound () { | ||
console.log('New content is downloading.') | ||
}, | ||
updated (registration: any) { | ||
console.log('New content is available; please refresh.') | ||
document.dispatchEvent(new CustomEvent('swUpdated', { detail: registration })) | ||
}, | ||
offline () { | ||
console.log('No internet connection found. App is running in offline mode.') | ||
}, | ||
error (error: any) { | ||
console.error('Error during service worker registration:', error) | ||
} | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters