v_1.11.4h1 notify_android_lost_subscription

This commit is contained in:
ostertun
2020-12-09 13:53:17 +01:00
parent 07d01ae700
commit 2c8c99b8f0
2 changed files with 21 additions and 2 deletions

View File

@@ -362,6 +362,7 @@ function pushesSubscribe() {
log('[app] Subscription:', subscription); log('[app] Subscription:', subscription);
if (await pushesUpdateServerSubscription(subscription, true)) { if (await pushesUpdateServerSubscription(subscription, true)) {
log('[app] Subscription: Sent to server, updating UI'); log('[app] Subscription: Sent to server, updating UI');
dbSettingsSet('notify_endpoint_' + BOATCLASS, subscription.endpoint);
updatePushSwitches(); updatePushSwitches();
updatePushBadge(); updatePushBadge();
} else { } else {
@@ -395,6 +396,7 @@ function pushesUnSubscribe(silent = false) {
subscription.unsubscribe(); subscription.unsubscribe();
log('[app] Subscription: Updating UI'); log('[app] Subscription: Updating UI');
$('#menu-pushes').hideMenu(); $('#menu-pushes').hideMenu();
dbSettingsSet('notify_endpoint_' + BOATCLASS, false);
updatePushBadge(); updatePushBadge();
hideLoader(); hideLoader();
if (!silent) toastOk('Du erhältst ab sofort keine Benachrichtigungen mehr von uns.'); if (!silent) toastOk('Du erhältst ab sofort keine Benachrichtigungen mehr von uns.');
@@ -510,12 +512,29 @@ function updatePushBadge() {
$('#badge-pushes').removeClass('bg-green2-dark').addClass('bg-red2-dark').text('BLOCKED'); $('#badge-pushes').removeClass('bg-green2-dark').addClass('bg-red2-dark').text('BLOCKED');
return; return;
} }
swRegistration.pushManager.getSubscription().then(function(subscription) { swRegistration.pushManager.getSubscription().then(async function(subscription) {
var dbSub = await dbSettingsGet('notify_endpoint_' + BOATCLASS);
var isSub = (subscription !== null); var isSub = (subscription !== null);
log('[app] DB Subscription:', dbSub);
log('[app] Real Subscription:', subscription);
if (isSub) { if (isSub) {
$('#badge-pushes').removeClass('bg-red2-dark').addClass('bg-green2-dark').text('AN'); $('#badge-pushes').removeClass('bg-red2-dark').addClass('bg-green2-dark').text('AN');
if (dbSub === null) dbSettingsSet('notify_endpoint_' + BOATCLASS, subscription.endpoint);
else if (dbSub !== subscription.endpoint) {
if (navigator.onLine) {
log('[app] Updating subscription');
pushesSubscribe();
}
}
} else { } else {
$('#badge-pushes').removeClass('bg-green2-dark').addClass('bg-red2-dark').text('AUS'); $('#badge-pushes').removeClass('bg-green2-dark').addClass('bg-red2-dark').text('AUS');
if (dbSub === null) dbSettingsSet('notify_endpoint_' + BOATCLASS, false);
else if (dbSub !== false) {
if (navigator.onLine) {
log('[app] Re subscribe');
pushesSubscribe();
}
}
} }
}); });
} }

View File

@@ -1,5 +1,5 @@
<?php <?php
define('PWA_VERSION', '1.11.4'); define('PWA_VERSION', '1.11.4h1');
?> ?>