Sweep: r.ok-Check bei allen direkten fetch('/api/...')-Aufrufen (SW-503-JSON-Falle)

5 Fundstellen nach dem Marker-Bug-Muster (v1224) gefixt:
- landing-init.js: Stats-Zahlen waeren offline NaN geworden
- social.js: Medien-Upload-Fehler wurde verschluckt (kein ok-Check, kein catch)
- routes.js: Unterwegs-POIs — {detail:...}.filter warf statt sauber []
- map.js: Marker-Melden zeigte Erfolgs-Toast obwohl Request fehlschlug
- settings.js: Update-Check meldete offline faelschlich 'ist aktuell'
Rest geprueft: api.js-Wrapper, wiki/uebungen/trainingsplaene-Helper checken ok,
externe Dienste (Nominatim etc.) laufen nicht ueber den SW-/api/-Zweig.
Bump v1225
This commit is contained in:
rene 2026-06-06 11:42:05 +02:00
parent e6d6a3e697
commit 45534aa8ee
10 changed files with 35 additions and 20 deletions

View file

@ -3,7 +3,7 @@
Router, State-Management, Navigation, Initialisierung.
============================================================ */
const APP_VER = '1224'; // ← bei jedem Deploy mit Frontend-Änderungen erhöhen
const APP_VER = '1225'; // ← 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

@ -64,7 +64,8 @@ document.addEventListener('DOMContentLoaded', function() {
// Live-Zahlen
var fmt = new Intl.NumberFormat('de-DE');
fetch('/api/stats/public')
.then(function(r) { return r.json(); })
// r.ok prüfen: der SW antwortet offline mit 503+JSON ({detail:…}) → json() wirft nicht
.then(function(r) { if (!r.ok) throw new Error('stats ' + r.status); return r.json(); })
.then(function(d) {
function set(id, val) {
var el = document.getElementById(id);

View file

@ -1865,6 +1865,9 @@ window.Page_map = (() => {
credentials: 'include', body: JSON.stringify(body),
});
if (res.status === 401) { UI.toast.error('Bitte erst anmelden.'); return; }
// res.ok prüfen: SW antwortet offline mit 503+JSON → json() wirft nicht,
// sonst Erfolgs-Toast obwohl nichts gemeldet wurde. (202 = offline gequeued = ok.)
if (!res.ok) throw new Error(`report ${res.status}`);
const data = await res.json();
if (data.status === 'bereits_gemeldet') {
UI.toast.info('Du hast diesen Marker bereits gemeldet.');

View file

@ -2762,8 +2762,11 @@ window.Page_routes = (() => {
await Promise.all(NEARBY_TYPES.map(async ({ type, icon, label, svgIcon, color }) => {
try {
const params = new URLSearchParams({ type, fast: 'true', ...bbox });
const pois = await fetch(`/api/osm/pois?${params}`).then(r => r.json());
pois
// r.ok prüfen: SW antwortet offline mit 503+JSON ({detail:…}) → json() wirft nicht
const r = await fetch(`/api/osm/pois?${params}`);
if (!r.ok) throw new Error(`pois ${r.status}`);
const pois = await r.json();
(Array.isArray(pois) ? pois : [])
.filter(p => _isNearTrack(p, track, 100)) // max 100m vom Track-Verlauf
.forEach(p => results.push({ ...p, _icon: icon, _label: label, _svgIcon: svgIcon, _color: color }));
} catch {}

View file

@ -1346,6 +1346,9 @@ window.Page_settings = (() => {
try {
// Versionsnummer direkt vom API-Endpunkt holen
const r = await fetch('/api/version', { cache: 'no-store' });
// r.ok prüfen: SW antwortet offline mit 503+JSON → json() wirft nicht und
// serverVersion=undefined meldete fälschlich „Ban Yaro ist aktuell".
if (!r.ok) throw new Error(`version ${r.status}`);
const { version: serverVersion } = await r.json();
const localVersion = typeof APP_VER !== 'undefined' ? APP_VER : '0';

View file

@ -377,7 +377,12 @@ window.Page_social = (() => {
method: 'POST',
headers: {Authorization: `Bearer ${localStorage.getItem('by_token')}`},
body: fd,
}).then(r => r.json()).then(d => { uploadedMediaUrl = d.url; });
}).then(r => {
// r.ok prüfen: SW antwortet offline mit 503+JSON → json() wirft nicht, d.url wäre undefined
if (!r.ok) throw new Error(`upload ${r.status}`);
return r.json();
}).then(d => { uploadedMediaUrl = d.url; })
.catch(() => UI.toast.error('Medien-Upload fehlgeschlagen.'));
};
reader.readAsDataURL(file);
}