Fix: Freunde Annehmen/Ablehnen/Chat per Event-Delegation statt Inline-onclick (von CSP-Härtung 65cfa25 blockiert), SW v1163

This commit is contained in:
rene 2026-06-04 13:35:53 +02:00
parent 55b354e865
commit 152fde716c
6 changed files with 35 additions and 20 deletions

View file

@ -3,7 +3,7 @@
Router, State-Management, Navigation, Initialisierung.
============================================================ */
const APP_VER = '1162'; // ← bei jedem Deploy mit Frontend-Änderungen erhöhen
const APP_VER = '1163'; // ← bei jedem Deploy mit Frontend-Änderungen erhöhen
const APP_VERSION = '1.6.0'; // ← semantische Version, wird bei make release gesetzt
window.APP_VER = APP_VER; // global verfügbar für andere Module (z.B. offline-indicator)
window.APP_VERSION = APP_VERSION;

View file

@ -148,6 +148,21 @@ window.Page_friends = (() => {
_searchTimer = setTimeout(() => _doSearch(q), 380);
});
// Delegierter Click-Handler — robust auch unter strikter CSP / für
// dynamisch nachgerenderte Buttons (Anfragen, Freundesliste).
// Ersetzt Inline-onclick, das auf manchen iOS-PWA-Sessions nicht feuerte.
_container.addEventListener('click', e => {
const btn = e.target.closest('[data-fr-action]');
if (!btn) return;
const id = parseInt(btn.dataset.frId, 10);
switch (btn.dataset.frAction) {
case 'accept': _accept(id); break;
case 'decline': _decline(id); break;
case 'cancel': _cancel(id); break;
case 'chat': _openChat(id); break;
}
});
// Prefill aus URL-Parameter → sofort suchen
if (prefill && prefill.length >= 2) {
_doSearch(prefill);
@ -359,12 +374,12 @@ window.Page_friends = (() => {
</div>
<div style="display:flex;gap:var(--space-2);flex-shrink:0">
<button class="btn btn-primary btn-sm"
onclick="Page_friends._accept(${r.id})" title="Annehmen">
data-fr-action="accept" data-fr-id="${r.id}" title="Annehmen">
<svg class="ph-icon"><use href="/icons/phosphor.svg#check"></use></svg>
Annehmen
</button>
<button class="btn btn-ghost btn-sm"
onclick="Page_friends._decline(${r.id})" title="Ablehnen">
data-fr-action="decline" data-fr-id="${r.id}" title="Ablehnen">
<svg class="ph-icon"><use href="/icons/phosphor.svg#x"></use></svg>
Ablehnen
</button>
@ -402,7 +417,7 @@ window.Page_friends = (() => {
<div class="text-xs-muted">Anfrage ausstehend</div>
</div>
<button class="btn btn-ghost btn-sm"
onclick="Page_friends._cancel(${r.id})" title="Zurückziehen">
data-fr-action="cancel" data-fr-id="${r.id}" title="Zurückziehen">
<svg class="ph-icon"><use href="/icons/phosphor.svg#x"></use></svg>
</button>
</div>
@ -514,7 +529,7 @@ window.Page_friends = (() => {
<svg class="ph-icon"><use href="/icons/phosphor.svg#note-pencil"></use></svg>
</button>
<button class="btn btn-ghost btn-sm"
onclick="Page_friends._openChat(${f.friend_id})"
data-fr-action="chat" data-fr-id="${f.friend_id}"
title="Nachricht schreiben">
<svg class="ph-icon"><use href="/icons/phosphor.svg#chat-circle-dots"></use></svg>
</button>