diff --git a/frontend/messages/de.json b/frontend/messages/de.json index dcd08246..c6659b13 100644 --- a/frontend/messages/de.json +++ b/frontend/messages/de.json @@ -522,6 +522,7 @@ "notification_filter_unread": "Ungelesen", "notification_filter_mention": "Erwähnung", "notification_filter_reply": "Antwort", + "notification_error_generic": "Aktion fehlgeschlagen. Bitte versuche es erneut.", "notification_mark_all_read_aria": "Alle Benachrichtigungen als gelesen markieren", "notification_load_more": "Ältere laden", "notification_empty_history": "Keine Benachrichtigungen", diff --git a/frontend/messages/en.json b/frontend/messages/en.json index f915633e..6991e87e 100644 --- a/frontend/messages/en.json +++ b/frontend/messages/en.json @@ -522,6 +522,7 @@ "notification_filter_unread": "Unread", "notification_filter_mention": "Mention", "notification_filter_reply": "Reply", + "notification_error_generic": "Action failed. Please try again.", "notification_mark_all_read_aria": "Mark all notifications as read", "notification_load_more": "Load older", "notification_empty_history": "No notifications", diff --git a/frontend/messages/es.json b/frontend/messages/es.json index 1f1dec02..d77c4389 100644 --- a/frontend/messages/es.json +++ b/frontend/messages/es.json @@ -522,6 +522,7 @@ "notification_filter_unread": "No leídas", "notification_filter_mention": "Mención", "notification_filter_reply": "Respuesta", + "notification_error_generic": "La acción ha fallado. Por favor, inténtalo de nuevo.", "notification_mark_all_read_aria": "Marcar todas las notificaciones como leídas", "notification_load_more": "Cargar anteriores", "notification_empty_history": "Sin notificaciones", diff --git a/frontend/src/lib/notification/NotificationDropdown.svelte b/frontend/src/lib/notification/NotificationDropdown.svelte index 903ed5ce..09719c4a 100644 --- a/frontend/src/lib/notification/NotificationDropdown.svelte +++ b/frontend/src/lib/notification/NotificationDropdown.svelte @@ -15,6 +15,8 @@ type Props = { let { notifications, optimisticMarkRead, optimisticMarkAllRead, onClose }: Props = $props(); +let errorMessage = $state(null); + function handleViewAll() { onClose(); // close first — avoids stale dropdown during navigation transition goto('/aktivitaeten'); @@ -38,7 +40,10 @@ function handleViewAll() { method="POST" use:enhance={() => { optimisticMarkAllRead(); - return async ({ update }) => { + return async ({ result, update }) => { + if (result.type === 'failure') { + errorMessage = (result.data as { error?: string } | undefined)?.error ?? m.notification_error_generic(); + } await update({ reset: false, invalidateAll: false }); }; }} @@ -53,6 +58,11 @@ function handleViewAll() { {/if} + + {#if errorMessage} +

{errorMessage}

+ {/if} + {#if notifications.length === 0} @@ -85,7 +95,9 @@ function handleViewAll() { use:enhance={() => { optimisticMarkRead(notification.id); return async ({ result, update }) => { - if (result.type !== 'failure') { + if (result.type === 'failure') { + errorMessage = (result.data as { error?: string } | undefined)?.error ?? m.notification_error_generic(); + } else { onClose(); goto( buildCommentHref(