fix(shopping): fix undo callback for list deletion

Replace local state mutation after list deletion with loadLists() so the
tab bar stays in sync with the server. Also add a renderTabs() call in
the error path so the UI recovers correctly on API failure.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Ulas Kalayci
2026-04-26 18:30:27 +02:00
parent 9fba1d7ae4
commit 28fe41962f
+4 -1
View File
@@ -786,13 +786,14 @@ function wireListContentEvents(container) {
let undone = false;
window.oikos.showToast(t('shopping.deletedListToast'), 'default', 5000, () => {
undone = true;
// Liste wurde nie optimistisch ausgeblendet → kein visuelles Restore nötig
});
setTimeout(async () => {
if (undone) return;
try {
await api.delete(`/shopping/${deletedListId}`);
state.lists = state.lists.filter((l) => l.id !== deletedListId);
await loadLists();
state.activeListId = state.lists[0]?.id ?? null;
if (state.activeListId) {
await switchList(state.activeListId, container);
@@ -804,6 +805,8 @@ function wireListContentEvents(container) {
}
} catch (err) {
window.oikos.showToast(err.message ?? t('common.unknownError'), 'danger');
await loadLists();
renderTabs(container);
}
}, 5000);
}