From ee96be76650a14cbeb930360fdf2460da9a34fca Mon Sep 17 00:00:00 2001 From: James Lyne Date: Thu, 20 May 2021 01:51:46 +0100 Subject: [PATCH] More thorough fix --- src/App.vue | 3 ++- src/store/mutation-types.ts | 2 ++ src/store/mutations.ts | 19 +++++++++++++++++++ 3 files changed, 23 insertions(+), 1 deletion(-) diff --git a/src/App.vue b/src/App.vue index c2110b4..700735e 100644 --- a/src/App.vue +++ b/src/App.vue @@ -133,7 +133,8 @@ export default defineComponent({ store.commit(MutationTypes.CLEAR_PLAYERS, undefined); store.commit(MutationTypes.CLEAR_CURRENT_MAP, undefined); store.commit(MutationTypes.CLEAR_PARSED_URL, undefined); - store.commit(MutationTypes.SET_WORLDS, []); + store.commit(MutationTypes.CLEAR_WORLDS, undefined); + store.commit(MutationTypes.CLEAR_MARKER_SETS, undefined); window.history.replaceState({}, '', newServer); loadConfiguration(); diff --git a/src/store/mutation-types.ts b/src/store/mutation-types.ts index 22bba34..9f5d967 100644 --- a/src/store/mutation-types.ts +++ b/src/store/mutation-types.ts @@ -21,8 +21,10 @@ export enum MutationTypes { CLEAR_CONFIGURATION_HASH = 'clearConfigurationHash', SET_MESSAGES = 'setMessages', SET_WORLDS = 'setWorlds', + CLEAR_WORLDS = 'clearWorlds', SET_COMPONENTS = 'setComponents', SET_MARKER_SETS = 'setMarkerSets', + CLEAR_MARKER_SETS = 'clearMarkerSets', ADD_WORLD = 'addWorld', SET_WORLD_STATE = 'setWorldState', SET_UPDATE_TIMESTAMP = 'setUpdateTimestamp', diff --git a/src/store/mutations.ts b/src/store/mutations.ts index cf41846..5ea8976 100644 --- a/src/store/mutations.ts +++ b/src/store/mutations.ts @@ -46,8 +46,10 @@ export type Mutations = { [MutationTypes.CLEAR_CONFIGURATION_HASH](state: S): void [MutationTypes.SET_MESSAGES](state: S, messages: DynmapMessageConfig): void [MutationTypes.SET_WORLDS](state: S, worlds: Array): void + [MutationTypes.CLEAR_WORLDS](state: S): void [MutationTypes.SET_COMPONENTS](state: S, worlds: DynmapComponentConfig): void [MutationTypes.SET_MARKER_SETS](state: S, worlds: Map): void + [MutationTypes.CLEAR_MARKER_SETS](state: S): void [MutationTypes.ADD_WORLD](state: S, world: DynmapWorld): void [MutationTypes.SET_WORLD_STATE](state: S, worldState: DynmapWorldState): void [MutationTypes.SET_UPDATE_TIMESTAMP](state: S, time: Date): void @@ -148,6 +150,18 @@ export const mutations: MutationTree & Mutations = { } }, + [MutationTypes.CLEAR_WORLDS](state: State) { + state.worlds.clear(); + state.maps.clear(); + + state.followTarget = undefined; + state.panTarget = undefined; + + state.currentWorldState.timeOfDay = 0; + state.currentWorldState.raining = false; + state.currentWorldState.thundering = false; + }, + //Sets the state and settings of optional components, from the initial config fetch [MutationTypes.SET_COMPONENTS](state: State, components: DynmapComponentConfig) { state.components = Object.assign(state.components, components); @@ -169,6 +183,11 @@ export const mutations: MutationTree & Mutations = { } }, + [MutationTypes.CLEAR_MARKER_SETS](state: State) { + state.markerSets.clear(); + state.pendingSetUpdates.clear(); + }, + [MutationTypes.ADD_WORLD](state: State, world: DynmapWorld) { state.worlds.set(world.name, world); },