mirror of
https://github.com/kiwix/kiwix-js-pwa.git
synced 2025-09-17 08:20:10 -04:00
Add logic for checking installed version
Former-commit-id: e1b6e37af929fc9fbb2d6608d6532939fac6ce41 [formerly ceaf7091f8e2d8e94cbd8e7d725962b3a148f68e] Former-commit-id: d77eca66500e9441c2d1bf9ba13706802a4d4fbf
This commit is contained in:
parent
63eaa00374
commit
08765f0401
@ -79,6 +79,7 @@ params['allowInternetAccess'] = params['allowInternetAccess'] || false; //Do not
|
||||
params['printIntercept'] = false;
|
||||
params['printInterception'] = false;
|
||||
params['appIsLaunching'] = true; //Allows some routines to tell if the app has just been launched
|
||||
params['PWAInstalled'] = getCookie('PWAInstalled');
|
||||
|
||||
//Prevent app boot loop with problematic pages that cause an app crash
|
||||
if (getCookie('lastPageLoad') == 'failed') {
|
||||
@ -183,6 +184,8 @@ window.addEventListener('beforeinstallprompt', function(e) {
|
||||
console.log('beforeinstallprompt fired');
|
||||
// Prevent Chrome 76 and earlier from automatically showing a prompt
|
||||
e.preventDefault();
|
||||
// Don't display prompt if the PWA for this version is already installed
|
||||
if (params.PWAInstalled === params.version) return;
|
||||
// Stash the event so it can be triggered later.
|
||||
deferredPrompt = e;
|
||||
// Show the install button
|
||||
@ -215,6 +218,11 @@ function installApp(e) {
|
||||
});
|
||||
}
|
||||
|
||||
window.addEventListener('appinstalled', function(e) {
|
||||
params.PWAInstalled = params.version;
|
||||
document.cookie = 'PWAInstalled=' + params.PWAInstalled + ';expires=Fri, 31 Dec 9999 23:59:59 GMT';
|
||||
});
|
||||
|
||||
function getCookie(name) {
|
||||
var result;
|
||||
if (params.cookieSupport == 'cookie') {
|
||||
|
Loading…
x
Reference in New Issue
Block a user