From 03ae9a048fdadc8c481427a9fc0d1d6f36d1ee30 Mon Sep 17 00:00:00 2001 From: Git'Fellow <12234510+solracsf@users.noreply.github.com> Date: Mon, 7 Sep 2026 13:10:01 +0200 Subject: [PATCH] fix(settings): report failures of the admin email toggle `OCP.AppConfig.setValue()` dispatches asynchronously and reports failures through its error callback, never by throwing, so the try/catch around it could not fire. The success toast was shown unconditionally and before the request had even completed - including when it failed outright or when password confirmation was declined. It now uses the success and error callbacks, and rolls the optimistic mutation back when the write does not land, so the toggle keeps matching the server. Signed-off-by: Git'Fellow <12234510+solracsf@users.noreply.github.com> --- src/store/settings-store.ts | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/src/store/settings-store.ts b/src/store/settings-store.ts index 3027a8ba7..4b06135ad 100644 --- a/src/store/settings-store.ts +++ b/src/store/settings-store.ts @@ -282,14 +282,17 @@ const store = new createStore({ }, ) - try { - OCP.AppConfig.setValue('activity', 'enable_email', emailEnabled ? 'yes' : 'no') - - showSuccess(t('activity', 'Your settings have been updated.')) - } catch (error) { - showError(t('activity', 'Unable to save the settings')) - logger.error('An error occurred while saving the activity settings', { error }) - } + // setValue reports failures through the error callback, never by throwing + OCP.AppConfig.setValue('activity', 'enable_email', emailEnabled ? 'yes' : 'no', { + success() { + showSuccess(t('activity', 'Your settings have been updated.')) + }, + error(error: unknown) { + commit('TOGGLE_EMAIL_ENABLED', { emailEnabled: !emailEnabled }) + showError(t('activity', 'Unable to save the settings')) + logger.error('An error occurred while saving the activity settings', { error }) + }, + }) }, /**