Merge pull request #469 from SamR1/improve-ui-preferences-update
Client - change UI display only on login ou user preferences update
This commit is contained in:
commit
8543e9b320
2
fittrackee/dist/index.html
vendored
2
fittrackee/dist/index.html
vendored
@ -7,7 +7,7 @@
|
||||
<link rel="stylesheet" href="/static/css/fork-awesome.min.css"/>
|
||||
<link rel="stylesheet" href="/static/css/leaflet.css"/>
|
||||
<title>FitTrackee</title>
|
||||
<script type="module" crossorigin src="/static/index-0v1Cinoq.js"></script>
|
||||
<script type="module" crossorigin src="/static/index-SJb1QCEI.js"></script>
|
||||
<link rel="modulepreload" crossorigin href="/static/charts-_RwsDDkL.js">
|
||||
<link rel="modulepreload" crossorigin href="/static/maps-ZyuCPqes.js">
|
||||
<link rel="stylesheet" crossorigin href="/static/css/maps-B7qTrBCW.css">
|
||||
|
File diff suppressed because one or more lines are too long
@ -57,7 +57,7 @@ export const actions: ActionTree<IAuthUserState, IRootState> &
|
||||
AUTH_USER_STORE.MUTATIONS.UPDATE_AUTH_TOKEN,
|
||||
window.localStorage.authToken
|
||||
)
|
||||
context.dispatch(AUTH_USER_STORE.ACTIONS.GET_USER_PROFILE)
|
||||
context.dispatch(AUTH_USER_STORE.ACTIONS.GET_USER_PROFILE, true)
|
||||
}
|
||||
// after logout in another tab
|
||||
if (
|
||||
@ -118,13 +118,16 @@ export const actions: ActionTree<IAuthUserState, IRootState> &
|
||||
})
|
||||
},
|
||||
[AUTH_USER_STORE.ACTIONS.GET_USER_PROFILE](
|
||||
context: ActionContext<IAuthUserState, IRootState>
|
||||
context: ActionContext<IAuthUserState, IRootState>,
|
||||
updateUI: boolean = false
|
||||
): void {
|
||||
context.commit(ROOT_STORE.MUTATIONS.EMPTY_ERROR_MESSAGES)
|
||||
authApi
|
||||
.get('auth/profile')
|
||||
.then((res) => {
|
||||
if (res.data.status === 'success') {
|
||||
const profileNotLoaded =
|
||||
context.getters[AUTH_USER_STORE.GETTERS.IS_PROFILE_NOT_LOADED]
|
||||
context.commit(
|
||||
AUTH_USER_STORE.MUTATIONS.UPDATE_AUTH_USER_PROFILE,
|
||||
res.data.data
|
||||
@ -133,6 +136,7 @@ export const actions: ActionTree<IAuthUserState, IRootState> &
|
||||
// refresh privacy policy
|
||||
context.dispatch(ROOT_STORE.ACTIONS.GET_APPLICATION_PRIVACY_POLICY)
|
||||
}
|
||||
if (profileNotLoaded || updateUI) {
|
||||
if (res.data.data.language) {
|
||||
context.dispatch(
|
||||
ROOT_STORE.ACTIONS.UPDATE_APPLICATION_LANGUAGE,
|
||||
@ -143,6 +147,7 @@ export const actions: ActionTree<IAuthUserState, IRootState> &
|
||||
ROOT_STORE.MUTATIONS.UPDATE_DARK_MODE,
|
||||
res.data.data.use_dark_mode
|
||||
)
|
||||
}
|
||||
context.dispatch(SPORTS_STORE.ACTIONS.GET_SPORTS)
|
||||
} else {
|
||||
handleError(context, null)
|
||||
@ -174,7 +179,7 @@ export const actions: ActionTree<IAuthUserState, IRootState> &
|
||||
window.localStorage.setItem('authToken', token)
|
||||
context.commit(AUTH_USER_STORE.MUTATIONS.UPDATE_AUTH_TOKEN, token)
|
||||
context
|
||||
.dispatch(AUTH_USER_STORE.ACTIONS.GET_USER_PROFILE)
|
||||
.dispatch(AUTH_USER_STORE.ACTIONS.GET_USER_PROFILE, true)
|
||||
.then(() =>
|
||||
router.push(
|
||||
typeof data.redirectUrl === 'string' ? data.redirectUrl : '/'
|
||||
|
@ -26,6 +26,7 @@ export enum AuthUserGetters {
|
||||
AUTH_USER_PROFILE = 'AUTH_USER_PROFILE',
|
||||
IS_ADMIN = 'IS_ADMIN',
|
||||
IS_AUTHENTICATED = 'IS_AUTHENTICATED',
|
||||
IS_PROFILE_NOT_LOADED = 'IS_PROFILE_NOT_LOADED',
|
||||
IS_SUCCESS = 'IS_SUCCESS',
|
||||
IS_REGISTRATION_SUCCESS = 'IS_REGISTRATION_SUCCESS',
|
||||
USER_LOADING = 'USER_LOADING',
|
||||
|
@ -35,4 +35,7 @@ export const getters: GetterTree<IAuthUserState, IRootState> &
|
||||
[AUTH_USER_STORE.GETTERS.USER_LOADING]: (state: IAuthUserState) => {
|
||||
return state.loading
|
||||
},
|
||||
[AUTH_USER_STORE.GETTERS.IS_PROFILE_NOT_LOADED]: (state: IAuthUserState) => {
|
||||
return state.authUserProfile.username === undefined
|
||||
},
|
||||
}
|
||||
|
@ -47,7 +47,8 @@ export interface IAuthUserActions {
|
||||
): void
|
||||
|
||||
[AUTH_USER_STORE.ACTIONS.GET_USER_PROFILE](
|
||||
context: ActionContext<IAuthUserState, IRootState>
|
||||
context: ActionContext<IAuthUserState, IRootState>,
|
||||
updateUI: boolean
|
||||
): void
|
||||
|
||||
[AUTH_USER_STORE.ACTIONS.LOGIN_OR_REGISTER](
|
||||
@ -142,6 +143,10 @@ export interface IAuthUserGetters {
|
||||
|
||||
[AUTH_USER_STORE.GETTERS.IS_AUTHENTICATED](state: IAuthUserState): boolean
|
||||
|
||||
[AUTH_USER_STORE.GETTERS.IS_PROFILE_NOT_LOADED](
|
||||
state: IAuthUserState
|
||||
): boolean
|
||||
|
||||
[AUTH_USER_STORE.GETTERS.IS_REGISTRATION_SUCCESS](
|
||||
state: IAuthUserState
|
||||
): boolean
|
||||
|
Loading…
Reference in New Issue
Block a user