Simplify login logic

Let LOGIN action handle displaying the modal if required.
This commit is contained in:
James Lyne 2022-06-17 13:21:30 +01:00
parent fff8ad0994
commit 46c4e6d3eb
4 changed files with 8 additions and 4 deletions

View File

@ -194,7 +194,7 @@ export default defineComponent({
element: 'maps',
state: false,
});
store.commit(MutationTypes.SHOW_UI_MODAL, 'login');
store.dispatch(ActionTypes.LOGIN, null);
notify('Login required');
showSplashError('Login required', true, 1);
} else {

View File

@ -99,7 +99,7 @@
}
},
login = () => store.commit(MutationTypes.SHOW_UI_MODAL, 'login');
login = () => store.dispatch(ActionTypes.LOGIN, null);
watch(chatBoxVisible, newValue => {
if(newValue && sendingEnabled.value) {

View File

@ -104,7 +104,7 @@ export class LoginControl extends Control {
notify(logoutError.value);
}
} else {
this.store.commit(MutationTypes.SHOW_UI_MODAL, 'login');
await this.store.dispatch(ActionTypes.LOGIN, null)
}
}
}

View File

@ -202,7 +202,11 @@ export const actions: ActionTree<State, State> & Actions = {
},
async [ActionTypes.LOGIN]({state, commit}, data: any): Promise<void> {
await state.currentMapProvider!.login(data);
if(data) {
await state.currentMapProvider!.login(data);
} else {
commit(MutationTypes.SHOW_UI_MODAL, 'login');
}
},
async [ActionTypes.LOGOUT]({state}): Promise<void> {