FCM: Debug-Popup und doppelte Diagnoseausgaben entfernen
This commit is contained in:
1 parent
d2be8e0d69
commit
b53dd11f1c
6 files changed
+15
-141
No files matched your search
@@ -5,7 +5,7 @@
|
||||
* damit er sowohl die mobilen Views als auch die statischen Assets
|
||||
* kontrolliert. Der Cache-Name wird pro App-Wurzel gebildet.
|
||||
*/
|
||||
const VERSION = 'cmbnet-pwa-v26';
|
||||
const VERSION = 'cmbnet-pwa-v27';
|
||||
const BASE = new URL('./', self.location).href;
|
||||
const SHELL_CACHE = `${VERSION}-shell`;
|
||||
const TILE_CACHE = `${VERSION}-tiles`;
|
||||
|
||||
@@ -420,9 +420,6 @@ async function initFirebasePush(registration = null, force = false) {
|
||||
&& payload.data.reason
|
||||
? payload.data.reason
|
||||
: 'wake';
|
||||
// Debugging: Jede im Vordergrund empfangene Firebase-Nachricht
|
||||
// wird sichtbar angezeigt, bevor die Synchronisierung läuft.
|
||||
showFirebaseDebugPopup(reason, payload);
|
||||
handlePushWake(reason);
|
||||
});
|
||||
}
|
||||
@@ -476,69 +473,10 @@ function initPushWakeListener() {
|
||||
if (!event.data || event.data.type !== 'cmbnet-wake') return;
|
||||
const port = event.ports && event.ports[0];
|
||||
const reason = event.data.reason || 'wake';
|
||||
// Ein Klick auf eine Benachrichtigung ist kein neuer Firebase-Empfang.
|
||||
if (reason !== 'notification') {
|
||||
showFirebaseDebugPopup(reason, event.data);
|
||||
}
|
||||
handlePushWake(reason, port);
|
||||
});
|
||||
}
|
||||
|
||||
function showFirebaseDebugPopup(reason, payload) {
|
||||
let dialog = document.getElementById('firebaseDebugDialog');
|
||||
if (!dialog) {
|
||||
dialog = document.createElement('dialog');
|
||||
dialog.id = 'firebaseDebugDialog';
|
||||
dialog.setAttribute('aria-labelledby', 'firebaseDebugTitle');
|
||||
|
||||
const article = document.createElement('article');
|
||||
const header = document.createElement('header');
|
||||
const title = document.createElement('h3');
|
||||
title.id = 'firebaseDebugTitle';
|
||||
title.textContent = 'Firebase-Nachricht';
|
||||
header.appendChild(title);
|
||||
|
||||
const body = document.createElement('div');
|
||||
body.className = 'dialog-body';
|
||||
const reasonEl = document.createElement('p');
|
||||
reasonEl.id = 'firebaseDebugReason';
|
||||
const payloadEl = document.createElement('pre');
|
||||
payloadEl.id = 'firebaseDebugPayload';
|
||||
payloadEl.className = 'firebase-debug-payload';
|
||||
body.append(reasonEl, payloadEl);
|
||||
|
||||
const footer = document.createElement('footer');
|
||||
const closeButton = document.createElement('button');
|
||||
closeButton.type = 'button';
|
||||
closeButton.className = 'secondary';
|
||||
closeButton.textContent = 'Schließen';
|
||||
closeButton.addEventListener('click', () => dialog.close());
|
||||
footer.appendChild(closeButton);
|
||||
|
||||
article.append(header, body, footer);
|
||||
dialog.appendChild(article);
|
||||
document.body.appendChild(dialog);
|
||||
}
|
||||
|
||||
const reasonEl = dialog.querySelector('#firebaseDebugReason');
|
||||
const payloadEl = dialog.querySelector('#firebaseDebugPayload');
|
||||
if (reasonEl) reasonEl.textContent = `Grund: ${reason || 'wake'}`;
|
||||
if (payloadEl) {
|
||||
let text = '';
|
||||
try {
|
||||
text = payload ? JSON.stringify(payload, null, 2) : '';
|
||||
} catch (error) {
|
||||
text = String(payload || '');
|
||||
}
|
||||
payloadEl.textContent = text;
|
||||
}
|
||||
|
||||
if (!dialog.open) {
|
||||
if (typeof dialog.showModal === 'function') dialog.showModal();
|
||||
else if (typeof dialog.show === 'function') dialog.show();
|
||||
}
|
||||
}
|
||||
|
||||
function waitForWsAuthentication(timeoutMs = PUSH_WAKE_AUTH_TIMEOUT_MS) {
|
||||
if (state.authenticated) return Promise.resolve(true);
|
||||
return new Promise(resolve => {
|
||||
|
||||
Reference in new issue
Block a user