Cleanup redundant useStore calls
This commit is contained in:
parent
56470790de
commit
0e57a50e0c
@ -71,7 +71,7 @@ export default defineComponent({
|
||||
},
|
||||
|
||||
handlePendingUpdates = async () => {
|
||||
const updates = await useStore().dispatch(ActionTypes.POP_CIRCLE_UPDATES, {
|
||||
const updates = await store.dispatch(ActionTypes.POP_CIRCLE_UPDATES, {
|
||||
markerSet: props.set.id,
|
||||
amount: 10,
|
||||
}),
|
||||
|
@ -70,7 +70,7 @@ export default defineComponent({
|
||||
},
|
||||
|
||||
handlePendingUpdates = async () => {
|
||||
const updates = await useStore().dispatch(ActionTypes.POP_LINE_UPDATES, {
|
||||
const updates = await store.dispatch(ActionTypes.POP_LINE_UPDATES, {
|
||||
markerSet: props.set.id,
|
||||
amount: 10,
|
||||
}),
|
||||
|
@ -70,7 +70,7 @@ export default defineComponent({
|
||||
},
|
||||
|
||||
handlePendingUpdates = async () => {
|
||||
const updates = await useStore().dispatch(ActionTypes.POP_MARKER_UPDATES, {
|
||||
const updates = await store.dispatch(ActionTypes.POP_MARKER_UPDATES, {
|
||||
markerSet: props.set.id,
|
||||
amount: 10,
|
||||
}),
|
||||
|
@ -62,7 +62,7 @@ export default defineComponent({
|
||||
messageHidden = computed(() => store.state.messages.followingHidden),
|
||||
|
||||
unfollow = () => {
|
||||
useStore().commit(MutationTypes.CLEAR_FOLLOW_TARGET, undefined);
|
||||
store.commit(MutationTypes.CLEAR_FOLLOW_TARGET, undefined);
|
||||
},
|
||||
updatePlayerImage = async () => {
|
||||
image.value = defaultImage;
|
||||
|
@ -60,13 +60,13 @@ export class CoordinatesControl extends Control {
|
||||
|
||||
if (this.options.showRegion) {
|
||||
this._regionContainer.textContent = '--------------';
|
||||
this._regionContainer.dataset.label = useStore().state.messages.locationRegion;
|
||||
this._regionContainer.dataset.label = store.state.messages.locationRegion;
|
||||
container.appendChild(this._regionContainer);
|
||||
}
|
||||
|
||||
if (this.options.showChunk) {
|
||||
this._chunkContainer.textContent = '----, ----';
|
||||
this._chunkContainer.dataset.label = useStore().state.messages.locationChunk;
|
||||
this._chunkContainer.dataset.label = store.state.messages.locationChunk;
|
||||
container.appendChild(this._chunkContainer);
|
||||
}
|
||||
|
||||
|
@ -39,7 +39,7 @@ export class LinkControl extends Control {
|
||||
copyErrorMessage = computed(() => store.state.messages.copyToClipboardError);
|
||||
|
||||
linkButton.type = 'button';
|
||||
linkButton.title = useStore().state.messages.linkTitle;
|
||||
linkButton.title = store.state.messages.linkTitle;
|
||||
linkButton.innerHTML = `
|
||||
<svg class="svg-icon" aria-hidden="true">
|
||||
<use xlink:href="#icon--link" />
|
||||
@ -47,7 +47,7 @@ export class LinkControl extends Control {
|
||||
|
||||
linkButton.addEventListener('click', e => {
|
||||
e.preventDefault();
|
||||
toClipboard(window.location.href.split("#")[0] + useStore().getters.url).then(() => {
|
||||
toClipboard(window.location.href.split("#")[0] + store.getters.url).then(() => {
|
||||
notify(copySuccessMessage.value);
|
||||
}).catch((e) => {
|
||||
notify({ type: 'error', text: copyErrorMessage.value });
|
||||
|
@ -30,7 +30,6 @@ import {
|
||||
import {
|
||||
DynmapMarkerSetUpdates, DynmapTileUpdate, DynmapUpdate
|
||||
} from "@/dynmap";
|
||||
import {useStore} from "@/store";
|
||||
import LiveAtlasMapDefinition from "@/model/LiveAtlasMapDefinition";
|
||||
import ChatError from "@/errors/ChatError";
|
||||
import {MutationTypes} from "@/store/mutation-types";
|
||||
@ -652,7 +651,7 @@ export default class DynmapMapProvider extends MapProvider {
|
||||
async populateWorld(world: LiveAtlasWorldDefinition): Promise<void> {
|
||||
const markerSets = await this.getMarkerSets(world);
|
||||
|
||||
useStore().commit(MutationTypes.SET_MARKER_SETS, markerSets);
|
||||
this.store.commit(MutationTypes.SET_MARKER_SETS, markerSets);
|
||||
}
|
||||
|
||||
private async getUpdate(): Promise<void> {
|
||||
@ -728,10 +727,8 @@ export default class DynmapMapProvider extends MapProvider {
|
||||
}
|
||||
|
||||
sendChatMessage(message: string) {
|
||||
const store = useStore();
|
||||
|
||||
if (!store.state.components.chatSending) {
|
||||
return Promise.reject(store.state.messages.chatErrorDisabled);
|
||||
if (!this.store.state.components.chatSending) {
|
||||
return Promise.reject(this.store.state.messages.chatErrorDisabled);
|
||||
}
|
||||
|
||||
return fetch(this.config.dynmap!.sendmessage, {
|
||||
@ -743,8 +740,8 @@ export default class DynmapMapProvider extends MapProvider {
|
||||
})
|
||||
}).then((response) => {
|
||||
if (response.status === 403) { //Rate limited
|
||||
throw new ChatError(store.state.messages.chatErrorCooldown
|
||||
.replace('%interval%', store.state.components.chatSending!.cooldown.toString()));
|
||||
throw new ChatError(this.store.state.messages.chatErrorCooldown
|
||||
.replace('%interval%', this.store.state.components.chatSending!.cooldown.toString()));
|
||||
}
|
||||
|
||||
if (!response.ok) {
|
||||
@ -754,11 +751,11 @@ export default class DynmapMapProvider extends MapProvider {
|
||||
return response.json();
|
||||
}).then(response => {
|
||||
if (response.error !== 'none') {
|
||||
throw new ChatError(store.state.messages.chatErrorNotAllowed);
|
||||
throw new ChatError(this.store.state.messages.chatErrorNotAllowed);
|
||||
}
|
||||
}).catch(e => {
|
||||
if (!(e instanceof ChatError)) {
|
||||
console.error(store.state.messages.chatErrorUnknown);
|
||||
console.error(this.store.state.messages.chatErrorUnknown);
|
||||
console.trace(e);
|
||||
}
|
||||
|
||||
@ -810,13 +807,11 @@ export default class DynmapMapProvider extends MapProvider {
|
||||
}
|
||||
|
||||
async login(data: any) {
|
||||
const store = useStore();
|
||||
|
||||
if (!store.state.components.login && !store.state.loginRequired) {
|
||||
return Promise.reject(store.state.messages.loginErrorDisabled);
|
||||
if (!this.store.state.components.login && !this.store.state.loginRequired) {
|
||||
return Promise.reject(this.store.state.messages.loginErrorDisabled);
|
||||
}
|
||||
|
||||
store.commit(MutationTypes.SET_LOGGED_IN, false);
|
||||
this.store.commit(MutationTypes.SET_LOGGED_IN, false);
|
||||
|
||||
try {
|
||||
const body = new URLSearchParams();
|
||||
@ -832,27 +827,25 @@ export default class DynmapMapProvider extends MapProvider {
|
||||
|
||||
switch(response.result) {
|
||||
case 'success':
|
||||
store.commit(MutationTypes.SET_LOGGED_IN, true);
|
||||
this.store.commit(MutationTypes.SET_LOGGED_IN, true);
|
||||
return;
|
||||
|
||||
case 'loginfailed':
|
||||
return Promise.reject(store.state.messages.loginErrorIncorrect);
|
||||
return Promise.reject(this.store.state.messages.loginErrorIncorrect);
|
||||
|
||||
default:
|
||||
return Promise.reject(store.state.messages.loginErrorUnknown);
|
||||
return Promise.reject(this.store.state.messages.loginErrorUnknown);
|
||||
}
|
||||
} catch(e) {
|
||||
console.error(store.state.messages.loginErrorUnknown);
|
||||
console.error(this.store.state.messages.loginErrorUnknown);
|
||||
console.trace(e);
|
||||
return Promise.reject(store.state.messages.loginErrorUnknown);
|
||||
return Promise.reject(this.store.state.messages.loginErrorUnknown);
|
||||
}
|
||||
}
|
||||
|
||||
async logout() {
|
||||
const store = useStore();
|
||||
|
||||
if (!store.state.components.login && !store.state.loginRequired) {
|
||||
return Promise.reject(store.state.messages.loginErrorDisabled);
|
||||
if (!this.store.state.components.login && !this.store.state.loginRequired) {
|
||||
return Promise.reject(this.store.state.messages.loginErrorDisabled);
|
||||
}
|
||||
|
||||
try {
|
||||
@ -860,20 +853,18 @@ export default class DynmapMapProvider extends MapProvider {
|
||||
method: 'POST',
|
||||
});
|
||||
|
||||
store.commit(MutationTypes.SET_LOGGED_IN, false);
|
||||
this.store.commit(MutationTypes.SET_LOGGED_IN, false);
|
||||
} catch(e) {
|
||||
return Promise.reject(store.state.messages.logoutErrorUnknown);
|
||||
return Promise.reject(this.store.state.messages.logoutErrorUnknown);
|
||||
}
|
||||
}
|
||||
|
||||
async register(data: any) {
|
||||
const store = useStore();
|
||||
|
||||
if (!store.state.components.login && !store.state.loginRequired) {
|
||||
return Promise.reject(store.state.messages.loginErrorDisabled);
|
||||
if (!this.store.state.components.login && !this.store.state.loginRequired) {
|
||||
return Promise.reject(this.store.state.messages.loginErrorDisabled);
|
||||
}
|
||||
|
||||
store.commit(MutationTypes.SET_LOGGED_IN, false);
|
||||
this.store.commit(MutationTypes.SET_LOGGED_IN, false);
|
||||
|
||||
try {
|
||||
const body = new URLSearchParams();
|
||||
@ -890,22 +881,22 @@ export default class DynmapMapProvider extends MapProvider {
|
||||
|
||||
switch(response.result) {
|
||||
case 'success':
|
||||
store.commit(MutationTypes.SET_LOGGED_IN, true);
|
||||
this.store.commit(MutationTypes.SET_LOGGED_IN, true);
|
||||
return;
|
||||
|
||||
case 'verifyfailed':
|
||||
return Promise.reject(store.state.messages.registerErrorVerifyFailed);
|
||||
return Promise.reject(this.store.state.messages.registerErrorVerifyFailed);
|
||||
|
||||
case 'registerfailed':
|
||||
return Promise.reject(store.state.messages.registerErrorIncorrect);
|
||||
return Promise.reject(this.store.state.messages.registerErrorIncorrect);
|
||||
|
||||
default:
|
||||
return Promise.reject(store.state.messages.registerErrorUnknown);
|
||||
return Promise.reject(this.store.state.messages.registerErrorUnknown);
|
||||
}
|
||||
} catch(e) {
|
||||
console.error(store.state.messages.registerErrorUnknown);
|
||||
console.error(this.store.state.messages.registerErrorUnknown);
|
||||
console.trace(e);
|
||||
return Promise.reject(store.state.messages.registerErrorUnknown);
|
||||
return Promise.reject(this.store.state.messages.registerErrorUnknown);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user