fix(web): bind UI handlers before first fetch so a data error can't kill the UI

initCalendar() awaited fetchAndRender() BEFORE binding the topbar/settings/menu
handlers, so any error from /caldav/events (e.g. a transient 500) threw out of
init and left the buttons dead — the reported "settings won't open". Same root
cause as the reload-logout bug: app wiring must not depend on event data loading.

Bind all handlers first, then fetch inside try/catch (errors are logged + shown
as a toast, no longer fatal). v75.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Scarriffle
2026-07-06 21:44:32 +02:00
parent 1eecf834a3
commit 90bc4b1531
2 changed files with 11 additions and 2 deletions

View File

@@ -135,7 +135,10 @@ export async function initCalendar() {
updateViewButtons();
renderCalendarList();
renderMiniCal();
await fetchAndRender();
// Bind all UI handlers BEFORE the first data fetch. Otherwise a failing
// /caldav/events (e.g. a transient server error) would throw out of
// initCalendar and leave the topbar/settings/menu buttons dead — the
// "settings won't open" bug. Handlers must not depend on event data loading.
bindTopbar();
bindSidebar();
bindEventModal();
@@ -149,6 +152,12 @@ export async function initCalendar() {
bindSwipeNavigation();
handleHAOAuthReturn();
loadGroups();
try {
await fetchAndRender();
} catch (e) {
console.error('Initial fetchAndRender failed', e);
showToast(t('unknown_error'), true);
}
// Reopen the settings modal after a reload if the URL says we were in it.
if (urlState.settings) openSettingsModal();

View File

@@ -1,2 +1,2 @@
// Increment APP_VERSION with every code change
export const APP_VERSION = 'v74';
export const APP_VERSION = 'v75';