Move loginRequired state into store, reset login related state in RESET
This commit is contained in:
parent
b2f58f681c
commit
12632004d1
13
src/App.vue
13
src/App.vue
@ -56,9 +56,9 @@ export default defineComponent({
|
||||
chatBoxEnabled = computed(() => store.state.components.chatBox),
|
||||
chatVisible = computed(() => store.state.ui.visibleElements.has('chat')),
|
||||
|
||||
loginEnabled = computed(() => store.state.components.login), //Whether logging in is enabled for the current server
|
||||
loggedIn = computed(() => store.state.loggedIn), //Whether the user is currently logged in
|
||||
loginRequired = ref(false), //Whether logging is required to view the current server
|
||||
loginRequired = computed(() => store.state.loginRequired), //Whether logging is required to view the current server
|
||||
loginEnabled = computed(() => store.state.components.login || loginRequired.value), //Whether logging in is enabled for the current server
|
||||
|
||||
//Hide the login modal if we are logged out on a login-required server, but the server list is open
|
||||
//Allows switching servers without the modal overlapping
|
||||
@ -79,8 +79,6 @@ export default defineComponent({
|
||||
await store.dispatch(ActionTypes.LOAD_CONFIGURATION, undefined);
|
||||
await store.dispatch(ActionTypes.START_UPDATES, undefined);
|
||||
|
||||
loginRequired.value = false;
|
||||
|
||||
requestAnimationFrame(() => {
|
||||
hideSplash();
|
||||
|
||||
@ -96,9 +94,8 @@ export default defineComponent({
|
||||
return;
|
||||
}
|
||||
|
||||
//Logging in is required, show login modal
|
||||
if(e.message === 'login-required') {
|
||||
loginRequired.value = true;
|
||||
//Logging in is required
|
||||
if(loginRequired.value) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -211,6 +208,8 @@ export default defineComponent({
|
||||
store.commit(MutationTypes.SHOW_UI_MODAL, 'login');
|
||||
notify('Login required');
|
||||
showSplashError('Login required', true, 1);
|
||||
} else {
|
||||
store.commit(MutationTypes.HIDE_UI_MODAL, 'login');
|
||||
}
|
||||
})
|
||||
|
||||
|
@ -629,8 +629,7 @@ export default class DynmapMapProvider extends MapProvider {
|
||||
const response = await DynmapMapProvider.getJSON(this.config.dynmap!.configuration, this.configurationAbort.signal);
|
||||
|
||||
if(response.error === 'login-required') {
|
||||
this.store.commit(MutationTypes.SET_LOGGED_IN, false);
|
||||
this.store.commit(MutationTypes.SET_COMPONENTS, {login: true});
|
||||
this.store.commit(MutationTypes.SET_LOGIN_REQUIRED, true);
|
||||
}
|
||||
|
||||
if (response.error) {
|
||||
@ -813,7 +812,7 @@ export default class DynmapMapProvider extends MapProvider {
|
||||
async login(data: any) {
|
||||
const store = useStore();
|
||||
|
||||
if (!store.state.components.login) {
|
||||
if (!store.state.components.login && !store.state.loginRequired) {
|
||||
return Promise.reject(store.state.messages.loginErrorDisabled);
|
||||
}
|
||||
|
||||
@ -852,7 +851,7 @@ export default class DynmapMapProvider extends MapProvider {
|
||||
async logout() {
|
||||
const store = useStore();
|
||||
|
||||
if (!store.state.components.login) {
|
||||
if (!store.state.components.login && !store.state.loginRequired) {
|
||||
return Promise.reject(store.state.messages.loginErrorDisabled);
|
||||
}
|
||||
|
||||
@ -870,7 +869,7 @@ export default class DynmapMapProvider extends MapProvider {
|
||||
async register(data: any) {
|
||||
const store = useStore();
|
||||
|
||||
if (!store.state.components.login) {
|
||||
if (!store.state.components.login && !store.state.loginRequired) {
|
||||
return Promise.reject(store.state.messages.loginErrorDisabled);
|
||||
}
|
||||
|
||||
|
@ -385,9 +385,6 @@ export default class Pl3xmapMapProvider extends MapProvider {
|
||||
this.store.commit(MutationTypes.SET_SERVER_MESSAGES, Pl3xmapMapProvider.buildMessagesConfig(response));
|
||||
this.store.commit(MutationTypes.SET_WORLDS, this.buildWorlds(response, worldResponses));
|
||||
this.store.commit(MutationTypes.SET_COMPONENTS, Pl3xmapMapProvider.buildComponents(response));
|
||||
|
||||
//Pl3xmap has no login functionality
|
||||
this.store.commit(MutationTypes.SET_LOGGED_IN, false);
|
||||
}
|
||||
|
||||
async populateWorld(world: LiveAtlasWorldDefinition) {
|
||||
|
@ -59,5 +59,6 @@ export enum MutationTypes {
|
||||
TOGGLE_SIDEBAR_SECTION_COLLAPSED_STATE = 'toggleSidebarSectionCollapsedState',
|
||||
|
||||
SET_LOGGED_IN = 'setLoggedIn',
|
||||
SET_LOGIN_REQUIRED = 'setLoginRequired',
|
||||
RESET = 'reset'
|
||||
}
|
||||
|
@ -92,6 +92,7 @@ export type Mutations<S = State> = {
|
||||
[MutationTypes.TOGGLE_SIDEBAR_SECTION_COLLAPSED_STATE](state: S, section: LiveAtlasSidebarSection): void
|
||||
|
||||
[MutationTypes.SET_LOGGED_IN](state: S, payload: boolean): void
|
||||
[MutationTypes.SET_LOGIN_REQUIRED](state: S, payload: boolean): void
|
||||
[MutationTypes.RESET](state: S): void
|
||||
}
|
||||
|
||||
@ -620,6 +621,10 @@ export const mutations: MutationTree<State> & Mutations = {
|
||||
state.loggedIn = payload;
|
||||
},
|
||||
|
||||
[MutationTypes.SET_LOGIN_REQUIRED](state: State, payload: boolean): void {
|
||||
state.loginRequired = payload;
|
||||
},
|
||||
|
||||
//Cleanup for switching servers or reloading the configuration
|
||||
[MutationTypes.RESET](state: State): void {
|
||||
state.followTarget = undefined;
|
||||
@ -661,5 +666,8 @@ export const mutations: MutationTree<State> & Mutations = {
|
||||
|
||||
state.ui.visibleModal = undefined;
|
||||
state.chat.messages = [];
|
||||
|
||||
state.loggedIn = false;
|
||||
state.loginRequired = false;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user