Fix: Tagebuch Foto-Löschen — null-crash + 404-Cleanup, SW by-v1073
- 'null is not an object (wrap2.remove)': Wrapper-Div hat keine Klasse .diary-media-thumb-wrap → closest() lieferte null. Fallback auf btn.parentElement + Null-Check vor remove() - Bei 404 'Medium nicht gefunden' wird das verwaiste Foto jetzt trotzdem lokal aufgeräumt (entry.media_items + DOM), statt einen Error-Toast zu zeigen. Verwaiste Phantome verschwinden so beim ersten Lösch-Klick.
This commit is contained in:
parent
c03884cb81
commit
e5abdcab62
5 changed files with 26 additions and 18 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 = "1072" # muss mit APP_VER in app.js übereinstimmen
|
APP_VER = "1073" # 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():
|
||||||
|
|
|
||||||
|
|
@ -101,9 +101,9 @@
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<!-- CSS: Reihenfolge ist wichtig — ?v= zwingt Browser zur Neuladung -->
|
<!-- CSS: Reihenfolge ist wichtig — ?v= zwingt Browser zur Neuladung -->
|
||||||
<link rel="stylesheet" href="/css/design-system.css?v=1072">
|
<link rel="stylesheet" href="/css/design-system.css?v=1073">
|
||||||
<link rel="stylesheet" href="/css/layout.css?v=1072">
|
<link rel="stylesheet" href="/css/layout.css?v=1073">
|
||||||
<link rel="stylesheet" href="/css/components.css?v=1072">
|
<link rel="stylesheet" href="/css/components.css?v=1073">
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|
||||||
|
|
@ -616,10 +616,10 @@
|
||||||
<div id="modal-container"></div>
|
<div id="modal-container"></div>
|
||||||
|
|
||||||
<!-- JS: Reihenfolge ist wichtig — erst Basis, dann Features -->
|
<!-- JS: Reihenfolge ist wichtig — erst Basis, dann Features -->
|
||||||
<script src="/js/api.js?v=1072"></script>
|
<script src="/js/api.js?v=1073"></script>
|
||||||
<script src="/js/ui.js?v=1072"></script>
|
<script src="/js/ui.js?v=1073"></script>
|
||||||
<script src="/js/app.js?v=1072"></script>
|
<script src="/js/app.js?v=1073"></script>
|
||||||
<script src="/js/worlds.js?v=1072"></script>
|
<script src="/js/worlds.js?v=1073"></script>
|
||||||
|
|
||||||
<!-- Feature-Seiten werden lazy geladen -->
|
<!-- Feature-Seiten werden lazy geladen -->
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
Router, State-Management, Navigation, Initialisierung.
|
Router, State-Management, Navigation, Initialisierung.
|
||||||
============================================================ */
|
============================================================ */
|
||||||
|
|
||||||
const APP_VER = '1072'; // ← bei jedem Deploy mit Frontend-Änderungen erhöhen
|
const APP_VER = '1073'; // ← 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.
|
||||||
|
|
|
||||||
|
|
@ -1437,25 +1437,33 @@ window.Page_diary = (() => {
|
||||||
wrap.innerHTML = grid;
|
wrap.innerHTML = grid;
|
||||||
wrap.querySelectorAll('.diary-media-thumb-del').forEach(btn => {
|
wrap.querySelectorAll('.diary-media-thumb-del').forEach(btn => {
|
||||||
btn.addEventListener('click', async () => {
|
btn.addEventListener('click', async () => {
|
||||||
const wrap2 = btn.closest('.diary-media-thumb-wrap');
|
const wrap2 = btn.closest('.diary-media-thumb-wrap') || btn.parentElement;
|
||||||
const mediaId = btn.dataset.mediaId ? parseInt(btn.dataset.mediaId) : null;
|
const mediaId = btn.dataset.mediaId ? parseInt(btn.dataset.mediaId) : null;
|
||||||
const isLegacy = !!btn.dataset.legacy;
|
const isLegacy = !!btn.dataset.legacy;
|
||||||
btn.disabled = true;
|
btn.disabled = true;
|
||||||
|
let alreadyGone = false;
|
||||||
try {
|
try {
|
||||||
if (mediaId != null) {
|
if (mediaId != null) {
|
||||||
await API.diary.deleteMediaItem(_appState.activeDog.id, entry.id, mediaId);
|
await API.diary.deleteMediaItem(_appState.activeDog.id, entry.id, mediaId);
|
||||||
// aus entry.media_items entfernen
|
|
||||||
if (entry.media_items) entry.media_items = entry.media_items.filter(m => m.id !== mediaId);
|
|
||||||
} else if (isLegacy) {
|
} else if (isLegacy) {
|
||||||
await API.diary.deleteMedia(_appState.activeDog.id, entry.id);
|
await API.diary.deleteMedia(_appState.activeDog.id, entry.id);
|
||||||
entry.media_url = null;
|
|
||||||
}
|
}
|
||||||
wrap2.remove();
|
|
||||||
UI.toast.success('Medium entfernt.');
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
btn.disabled = false;
|
if (e?.status === 404) {
|
||||||
UI.toast.error(e.message || 'Fehler beim Löschen.');
|
alreadyGone = true; // serverseitig schon weg → trotzdem lokal aufräumen
|
||||||
|
} else {
|
||||||
|
btn.disabled = false;
|
||||||
|
UI.toast.error(e.message || 'Fehler beim Löschen.');
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
if (mediaId != null && entry.media_items) {
|
||||||
|
entry.media_items = entry.media_items.filter(m => m.id !== mediaId);
|
||||||
|
} else if (isLegacy) {
|
||||||
|
entry.media_url = null;
|
||||||
|
}
|
||||||
|
if (wrap2) wrap2.remove();
|
||||||
|
UI.toast.success(alreadyGone ? 'Verwaisten Eintrag aufgeräumt.' : 'Medium entfernt.');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
// Stern-Buttons im Edit-Formular
|
// Stern-Buttons im Edit-Formular
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
============================================================ */
|
============================================================ */
|
||||||
|
|
||||||
// ← EINZIGE Stelle für die Version — STATIC_ASSETS und CACHE_VERSION leiten sich ab
|
// ← EINZIGE Stelle für die Version — STATIC_ASSETS und CACHE_VERSION leiten sich ab
|
||||||
const VER = '1072';
|
const VER = '1073';
|
||||||
const CACHE_VERSION = `by-v${VER}`;
|
const CACHE_VERSION = `by-v${VER}`;
|
||||||
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
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue