1
0

feat: keep errorMessage local (#865)

Co-authored-by: Dominik Pschenitschni <mail@celement.de>
Co-authored-by: kolaente <k@knt.li>
Co-authored-by: konrad <k@knt.li>
Reviewed-on: https://kolaente.dev/vikunja/frontend/pulls/865
Co-authored-by: dpschen <dpschen@noreply.kolaente.de>
Co-committed-by: dpschen <dpschen@noreply.kolaente.de>
This commit is contained in:
dpschen
2021-10-17 19:38:30 +00:00
committed by konrad
parent 1fc857d9a2
commit 0a1d0084e2
6 changed files with 31 additions and 41 deletions

View File

@ -2,7 +2,6 @@ import {createStore} from 'vuex'
import {
BACKGROUND,
CURRENT_LIST,
ERROR_MESSAGE,
HAS_TASKS,
KEYBOARD_SHORTCUTS_ACTIVE,
LOADING,
@ -36,7 +35,6 @@ export const store = createStore({
state: {
loading: false,
loadingModule: null,
errorMessage: '',
online: true,
// This is used to highlight the current list in menu for all list related views
currentList: {id: 0},
@ -53,9 +51,6 @@ export const store = createStore({
[LOADING_MODULE](state, module) {
state.loadingModule = module
},
[ERROR_MESSAGE](state, error) {
state.errorMessage = error
},
[ONLINE](state, online) {
if (import.meta.env.VITE_IS_ONLINE) {
console.log('Setting fake online state', import.meta.env.VITE_IS_ONLINE)

View File

@ -1,5 +1,5 @@
import {HTTPFactory} from '@/http-common'
import {ERROR_MESSAGE, LOADING} from '../mutation-types'
import {LOADING} from '../mutation-types'
import UserModel from '../../models/user'
import {getToken, refreshToken, removeToken, saveToken} from '@/helpers/auth'
@ -128,8 +128,8 @@ export default {
})
return ctx.dispatch('login', credentials)
} catch(e) {
if (e.response && e.response.data && e.response.data.message) {
ctx.commit(ERROR_MESSAGE, e.response.data.message, {root: true})
if (e.response?.data?.message) {
throw e.response.data
}
throw e

View File

@ -1,6 +1,5 @@
export const LOADING = 'loading'
export const LOADING_MODULE = 'loadingModule'
export const ERROR_MESSAGE = 'errorMessage'
export const ONLINE = 'online'
export const CURRENT_LIST = 'currentList'
export const HAS_TASKS = 'hasTasks'