Fix: Routen-Aufzeichnung offline — Buttons Abbruch/Start reagieren nicht
L.map() warf ReferenceError wenn Leaflet offline nicht geladen → _openRecOvl() crashte, Event-Listener für #rk-rec-cancel und #rk-rec-startbtn wurden nie angehängt. Fix: - Listener direkt nach appendChild() registrieren (vor jeder async-Operation) - Map-Setup in try/catch; bei fehlendem Leaflet: Offline-Platzhalter im Map-Bereich - _recMap?.setView / _recLocMarker?.setLatLng mit Optional Chaining (null-safe) - SW by-v994, APP_VER 994
This commit is contained in:
parent
0878684402
commit
57192ea010
4 changed files with 29 additions and 16 deletions
|
|
@ -410,7 +410,7 @@ async def serve_media(path: str, request: _Request):
|
||||||
raise _HE(404, "Nicht gefunden.")
|
raise _HE(404, "Nicht gefunden.")
|
||||||
return _media_response(filepath)
|
return _media_response(filepath)
|
||||||
|
|
||||||
APP_VER = "993" # muss mit APP_VER in app.js übereinstimmen
|
APP_VER = "994" # muss mit APP_VER in app.js übereinstimmen
|
||||||
|
|
||||||
@app.get("/.well-known/assetlinks.json")
|
@app.get("/.well-known/assetlinks.json")
|
||||||
async def assetlinks():
|
async def assetlinks():
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
Router, State-Management, Navigation, Initialisierung.
|
Router, State-Management, Navigation, Initialisierung.
|
||||||
============================================================ */
|
============================================================ */
|
||||||
|
|
||||||
const APP_VER = '993'; // ← bei jedem Deploy mit Frontend-Änderungen erhöhen
|
const APP_VER = '994'; // ← bei jedem Deploy mit Frontend-Änderungen erhöhen
|
||||||
const APP_VERSION = '1.6.0'; // ← semantische Version, wird bei make release gesetzt
|
const APP_VERSION = '1.6.0'; // ← semantische Version, wird bei make release gesetzt
|
||||||
const IS_STAGING = location.hostname === 'staging.banyaro.app';
|
const IS_STAGING = location.hostname === 'staging.banyaro.app';
|
||||||
// Cache-Bust-Parameter nach Update-Reload sofort entfernen
|
// Cache-Bust-Parameter nach Update-Reload sofort entfernen
|
||||||
|
|
|
||||||
|
|
@ -726,24 +726,37 @@ window.Page_routes = (() => {
|
||||||
document.body.appendChild(ovl);
|
document.body.appendChild(ovl);
|
||||||
_recOvl = ovl;
|
_recOvl = ovl;
|
||||||
|
|
||||||
const pos = _userPos || { lat: 48.1, lon: 11.5 };
|
// Listener sofort nach DOM-Einfügen — nicht nach async-Operationen
|
||||||
_recMap = L.map(ovl.querySelector('#rk-rec-map-wrap'), { zoomControl: false, attributionControl: false })
|
ovl.querySelector('#rk-rec-cancel').addEventListener('click', () => _closeRecOvlClean());
|
||||||
.setView([pos.lat, pos.lon], 15);
|
ovl.querySelector('#rk-rec-startbtn').addEventListener('click', _startRecInOvl);
|
||||||
L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', { maxZoom: 19 }).addTo(_recMap);
|
|
||||||
_recLocMarker = L.circleMarker([pos.lat, pos.lon], {
|
|
||||||
radius: 8, color: '#fff', weight: 2.5, fillColor: '#3b82f6', fillOpacity: 1
|
|
||||||
}).addTo(_recMap);
|
|
||||||
|
|
||||||
// Get accurate position
|
// Map-Setup: Leaflet könnte offline fehlen → alles in try/catch
|
||||||
|
const pos = _userPos || { lat: 48.1, lon: 11.5 };
|
||||||
|
try {
|
||||||
|
if (!window.L) throw new Error('Leaflet not loaded');
|
||||||
|
_recMap = L.map(ovl.querySelector('#rk-rec-map-wrap'), { zoomControl: false, attributionControl: false })
|
||||||
|
.setView([pos.lat, pos.lon], 15);
|
||||||
|
L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', { maxZoom: 19 }).addTo(_recMap);
|
||||||
|
_recLocMarker = L.circleMarker([pos.lat, pos.lon], {
|
||||||
|
radius: 8, color: '#fff', weight: 2.5, fillColor: '#3b82f6', fillOpacity: 1
|
||||||
|
}).addTo(_recMap);
|
||||||
|
} catch {
|
||||||
|
const mapWrap = ovl.querySelector('#rk-rec-map-wrap');
|
||||||
|
if (mapWrap) mapWrap.innerHTML =
|
||||||
|
`<div style="display:flex;align-items:center;justify-content:center;height:100%;
|
||||||
|
flex-direction:column;gap:8px;color:var(--c-text-secondary);font-size:14px">
|
||||||
|
<span style="font-size:2rem">📡</span>
|
||||||
|
Karte offline nicht verfügbar — GPS läuft trotzdem
|
||||||
|
</div>`;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Genaueren Standort nachladen (best-effort, klappt auch offline via gespeichertem GPS)
|
||||||
try {
|
try {
|
||||||
const p = await API.getLocation();
|
const p = await API.getLocation();
|
||||||
_userPos = p;
|
_userPos = p;
|
||||||
_recMap.setView([p.lat, p.lon], 16);
|
_recMap?.setView([p.lat, p.lon], 16);
|
||||||
_recLocMarker.setLatLng([p.lat, p.lon]);
|
_recLocMarker?.setLatLng([p.lat, p.lon]);
|
||||||
} catch {}
|
} catch {}
|
||||||
|
|
||||||
ovl.querySelector('#rk-rec-cancel').addEventListener('click', () => _closeRecOvlClean());
|
|
||||||
ovl.querySelector('#rk-rec-startbtn').addEventListener('click', _startRecInOvl);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async function _startRecInOvl() {
|
async function _startRecInOvl() {
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
Offline-Cache + Push Notifications + Tile-Cache
|
Offline-Cache + Push Notifications + Tile-Cache
|
||||||
============================================================ */
|
============================================================ */
|
||||||
|
|
||||||
const CACHE_VERSION = 'by-v993';
|
const CACHE_VERSION = 'by-v994';
|
||||||
const CACHE_STATIC = `${CACHE_VERSION}-static`;
|
const CACHE_STATIC = `${CACHE_VERSION}-static`;
|
||||||
const CACHE_TILES = 'ban-yaro-tiles-v1'; // bleibt über SW-Updates erhalten
|
const CACHE_TILES = 'ban-yaro-tiles-v1'; // bleibt über SW-Updates erhalten
|
||||||
const CACHE_API = 'ban-yaro-api-v1'; // API-Response-Cache
|
const CACHE_API = 'ban-yaro-api-v1'; // API-Response-Cache
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue