Fix error toasts and event-delete state splitting
contacts/events bulk delete: format errors through getErrorMessage so
the toast shows the message string instead of "[object Object]".
events delete: state now stores upcomingEvents and pastEvents
separately; the old single-list filter never matched, so deleted
events lingered in the UI until reload. Filter the correct list.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2 files changed,
+19 insertions,
-7 deletions
| 60 |
60 |
|
GoingsOn.ui.showToast(`${count} contact${count > 1 ? 's' : ''} deleted`, 'success');
|
| 61 |
61 |
|
load();
|
| 62 |
62 |
|
} catch (err) {
|
| 63 |
|
- |
GoingsOn.ui.showToast('Failed to delete contacts: ' + err, 'error');
|
|
63 |
+ |
GoingsOn.ui.showToast('Failed to delete contacts: ' + GoingsOn.utils.getErrorMessage(err), 'error');
|
| 64 |
64 |
|
}
|
| 65 |
65 |
|
}
|
| 66 |
66 |
|
|
| 79 |
79 |
|
GoingsOn.ui.showToast(`Tagged ${affected} contact${affected !== 1 ? 's' : ''}`, 'success');
|
| 80 |
80 |
|
load();
|
| 81 |
81 |
|
} catch (err) {
|
| 82 |
|
- |
GoingsOn.ui.showToast('Failed to tag contacts: ' + err, 'error');
|
|
82 |
+ |
GoingsOn.ui.showToast('Failed to tag contacts: ' + GoingsOn.utils.getErrorMessage(err), 'error');
|
| 83 |
83 |
|
}
|
| 84 |
84 |
|
}
|
| 85 |
85 |
|
|
| 67 |
67 |
|
GoingsOn.ui.showToast(`${count} event${count > 1 ? 's' : ''} deleted`, 'success');
|
| 68 |
68 |
|
load();
|
| 69 |
69 |
|
} catch (err) {
|
| 70 |
|
- |
GoingsOn.ui.showToast('Failed to delete events: ' + err, 'error');
|
|
70 |
+ |
GoingsOn.ui.showToast('Failed to delete events: ' + GoingsOn.utils.getErrorMessage(err), 'error');
|
| 71 |
71 |
|
}
|
| 72 |
72 |
|
}
|
| 73 |
73 |
|
|
| 468 |
468 |
|
if (!await GoingsOn.ui.confirmDelete('event')) return;
|
| 469 |
469 |
|
|
| 470 |
470 |
|
GoingsOn.cache.invalidate('events');
|
| 471 |
|
- |
const cachedEvents = GoingsOn.state.events;
|
| 472 |
|
- |
const removedEvent = cachedEvents.find(e => e.id === id);
|
| 473 |
|
- |
GoingsOn.state.set('events', cachedEvents.filter(e => e.id !== id));
|
|
471 |
+ |
const upcoming = GoingsOn.state.upcomingEvents || [];
|
|
472 |
+ |
const past = GoingsOn.state.pastEvents || [];
|
|
473 |
+ |
const removedUpcoming = upcoming.find(e => e.id === id);
|
|
474 |
+ |
const removedPast = past.find(e => e.id === id);
|
|
475 |
+ |
const removedEvent = removedUpcoming || removedPast;
|
|
476 |
+ |
if (removedUpcoming) {
|
|
477 |
+ |
GoingsOn.state.set('upcomingEvents', upcoming.filter(e => e.id !== id));
|
|
478 |
+ |
}
|
|
479 |
+ |
if (removedPast) {
|
|
480 |
+ |
GoingsOn.state.set('pastEvents', past.filter(e => e.id !== id));
|
|
481 |
+ |
}
|
| 474 |
482 |
|
|
| 475 |
483 |
|
GoingsOn.ui.showUndoToast('Event deleted', {
|
| 476 |
484 |
|
onConfirm: async () => {
|
| 483 |
491 |
|
},
|
| 484 |
492 |
|
onUndo: () => {
|
| 485 |
493 |
|
if (removedEvent) {
|
| 486 |
|
- |
GoingsOn.state.set('events', [...GoingsOn.state.events, removedEvent]);
|
|
494 |
+ |
if (removedUpcoming) {
|
|
495 |
+ |
GoingsOn.state.set('upcomingEvents', [...(GoingsOn.state.upcomingEvents || []), removedEvent]);
|
|
496 |
+ |
} else {
|
|
497 |
+ |
GoingsOn.state.set('pastEvents', [...(GoingsOn.state.pastEvents || []), removedEvent]);
|
|
498 |
+ |
}
|
| 487 |
499 |
|
}
|
| 488 |
500 |
|
},
|
| 489 |
501 |
|
});
|