Move loginEnabled logic to store getter
This commit is contained in:
parent
0e57a50e0c
commit
63a00d0681
@ -58,7 +58,7 @@ export default defineComponent({
|
||||
|
||||
loggedIn = computed(() => store.state.loggedIn), //Whether the user is currently logged in
|
||||
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
|
||||
loginEnabled = computed(() => store.getters.loginEnabled), //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
|
||||
|
@ -807,7 +807,7 @@ export default class DynmapMapProvider extends MapProvider {
|
||||
}
|
||||
|
||||
async login(data: any) {
|
||||
if (!this.store.state.components.login && !this.store.state.loginRequired) {
|
||||
if (!this.store.getters.loginEnabled) {
|
||||
return Promise.reject(this.store.state.messages.loginErrorDisabled);
|
||||
}
|
||||
|
||||
@ -844,7 +844,7 @@ export default class DynmapMapProvider extends MapProvider {
|
||||
}
|
||||
|
||||
async logout() {
|
||||
if (!this.store.state.components.login && !this.store.state.loginRequired) {
|
||||
if (!this.store.getters.loginEnabled) {
|
||||
return Promise.reject(this.store.state.messages.loginErrorDisabled);
|
||||
}
|
||||
|
||||
@ -860,7 +860,7 @@ export default class DynmapMapProvider extends MapProvider {
|
||||
}
|
||||
|
||||
async register(data: any) {
|
||||
if (!this.store.state.components.login && !this.store.state.loginRequired) {
|
||||
if (!this.store.getters.loginEnabled) {
|
||||
return Promise.reject(this.store.state.messages.loginErrorDisabled);
|
||||
}
|
||||
|
||||
|
@ -22,6 +22,7 @@ export type Getters = {
|
||||
playerMarkersEnabled(state: State): boolean;
|
||||
coordinatesControlEnabled(state: State): boolean;
|
||||
clockControlEnabled(state: State): boolean;
|
||||
loginEnabled(state: State): boolean;
|
||||
night(state: State): boolean;
|
||||
mapBackground(state: State, getters: GetterTree<State, State> & Getters): string;
|
||||
url(state: State, getters: GetterTree<State, State> & Getters): string;
|
||||
@ -42,6 +43,10 @@ export const getters: GetterTree<State, State> & Getters = {
|
||||
return state.components.clockControl !== undefined;
|
||||
},
|
||||
|
||||
loginEnabled(state: State): boolean {
|
||||
return state.components.login || state.loginRequired;
|
||||
},
|
||||
|
||||
night(state: State): boolean {
|
||||
return getMinecraftTime(state.currentWorldState.timeOfDay).night;
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user