From 453cde8435da2ca32638125843d96bc0348d7823 Mon Sep 17 00:00:00 2001 From: Angelina Filippova Date: Thu, 24 Oct 2019 23:24:56 +0200 Subject: [PATCH] Move try/catch and success message from view files to action in module --- src/store/modules/settings.js | 13 +++++++++++-- src/views/settings/components/ActivityPub.vue | 13 ++----------- src/views/settings/components/Authentication.vue | 13 ++----------- src/views/settings/components/AutoLinker.vue | 13 ++----------- src/views/settings/components/Captcha.vue | 13 ++----------- src/views/settings/components/Database.vue | 13 ++----------- src/views/settings/components/Endpoint.vue | 13 ++----------- src/views/settings/components/Esshd.vue | 13 ++----------- src/views/settings/components/Frontend.vue | 13 ++----------- src/views/settings/components/Gopher.vue | 13 ++----------- src/views/settings/components/Http.vue | 13 ++----------- src/views/settings/components/Instance.vue | 13 ++----------- src/views/settings/components/JobQueue.vue | 13 ++----------- src/views/settings/components/Logger.vue | 13 ++----------- src/views/settings/components/MRF.vue | 13 ++----------- src/views/settings/components/Mailer.vue | 13 ++----------- src/views/settings/components/MediaProxy.vue | 13 ++----------- src/views/settings/components/Metadata.vue | 13 ++----------- src/views/settings/components/Other.vue | 13 ++----------- src/views/settings/components/RateLimiters.vue | 13 ++----------- src/views/settings/components/Upload.vue | 13 ++----------- src/views/settings/components/WebPush.vue | 13 ++----------- 22 files changed, 53 insertions(+), 233 deletions(-) diff --git a/src/store/modules/settings.js b/src/store/modules/settings.js index bb6bd8c1..9c3a2c79 100644 --- a/src/store/modules/settings.js +++ b/src/store/modules/settings.js @@ -1,5 +1,7 @@ +import i18n from '@/lang' import { fetchSettings, updateSettings, uploadMedia } from '@/api/settings' import { filterIgnored, parseTuples, valueHasTuples, wrapConfig } from './normalizers' +import { Message } from 'element-ui' const settings = { state: { @@ -124,10 +126,17 @@ const settings = { async SubmitChanges({ getters, commit, state }, data) { const filteredSettings = filterIgnored(state.settings, state.ignoredIfNotEnabled) const configs = data || wrapConfig(filteredSettings) - const response = await updateSettings(configs, getters.authHost, getters.token) - if (data) { + try { + const response = await updateSettings(configs, getters.authHost, getters.token) commit('SET_SETTINGS', response.data.configs) + } catch (_e) { + return } + Message({ + message: i18n.t('settings.success'), + type: 'success', + duration: 5 * 1000 + }) }, UpdateSettings({ commit }, { tab, data }) { commit('UPDATE_SETTINGS', { tab, data }) diff --git a/src/views/settings/components/ActivityPub.vue b/src/views/settings/components/ActivityPub.vue index 903e34fe..2067be0a 100644 --- a/src/views/settings/components/ActivityPub.vue +++ b/src/views/settings/components/ActivityPub.vue @@ -37,7 +37,6 @@