diff --git a/src/App.vue b/src/App.vue index d3f94f9..92f9a93 100644 --- a/src/App.vue +++ b/src/App.vue @@ -54,7 +54,7 @@ export default defineComponent({ loadConfiguration = () => { return store.dispatch(ActionTypes.LOAD_CONFIGURATION, undefined).then(() => { startUpdates(); - window.hideSplash(); + requestAnimationFrame(window.hideSplash); }).catch(e => { console.error('Failed to load server configuration: ', e); window.showSplashError(e, false, ++configAttempts.value); @@ -117,7 +117,6 @@ export default defineComponent({ stopUpdates(); window.history.replaceState({}, '', newServer); store.commit(MutationTypes.CLEAR_PARSED_URL, undefined); - store.commit(MutationTypes.CLEAR_CURRENT_ZOOM, undefined); loadConfiguration(); }); diff --git a/src/components/map/marker/PlayerMarker.vue b/src/components/map/marker/PlayerMarker.vue index 40bc15d..5b5d5ad 100644 --- a/src/components/map/marker/PlayerMarker.vue +++ b/src/components/map/marker/PlayerMarker.vue @@ -226,7 +226,7 @@ export default defineComponent({ this.updateChatBalloon(); }, currentWorld(newValue) { - if(newValue.name === this.player.location.world) { + if(newValue && newValue.name === this.player.location.world) { this.enableLayer(); } else if(this.markerVisible) { this.disableLayer(); diff --git a/src/main.ts b/src/main.ts index 7237f6f..a3a7d5f 100644 --- a/src/main.ts +++ b/src/main.ts @@ -41,9 +41,7 @@ window.showSplash = function() { splash.hidden = false; requestAnimationFrame(function() { - if(splash) { - splash.style.opacity = '1'; - } + splash.style.opacity = '1'; }); }; @@ -100,8 +98,6 @@ API.validateConfiguration().then((config) => { store.commit(MutationTypes.SET_CURRENT_SERVER, config.keys().next().value); } - console.log(store.state.currentServer); - const app = createApp(App).use(store); // app.config.performance = true; diff --git a/src/store/actions.ts b/src/store/actions.ts index 7b31ee1..5da8ae9 100644 --- a/src/store/actions.ts +++ b/src/store/actions.ts @@ -78,11 +78,11 @@ export interface Actions { export const actions: ActionTree & Actions = { [ActionTypes.LOAD_CONFIGURATION]({commit, state}): Promise { - commit(MutationTypes.CLEAR_MARKER_SETS, undefined); + //Cleanup in case we are switching servers commit(MutationTypes.CLEAR_PLAYERS, undefined); + commit(MutationTypes.CLEAR_CURRENT_MAP, undefined); return API.getConfiguration().then(config => { - commit(MutationTypes.CLEAR_WORLDS, undefined); commit(MutationTypes.SET_CONFIGURATION, config.config); commit(MutationTypes.SET_MESSAGES, config.messages); commit(MutationTypes.SET_WORLDS, config.worlds); diff --git a/src/store/mutation-types.ts b/src/store/mutation-types.ts index 308fec8..6383eaa 100644 --- a/src/store/mutation-types.ts +++ b/src/store/mutation-types.ts @@ -21,9 +21,7 @@ export enum MutationTypes { SET_WORLDS = 'setWorlds', SET_COMPONENTS = 'setComponents', SET_MARKER_SETS = 'setMarkerSets', - CLEAR_MARKER_SETS = 'clearMarkerSets', ADD_WORLD = 'addWorld', - CLEAR_WORLDS = 'clearWorlds', SET_WORLD_STATE = 'setWorldState', SET_UPDATE_TIMESTAMP = 'setUpdateTimestamp', ADD_MARKER_SET_UPDATES = 'addMarkerSetUpdates', @@ -44,9 +42,9 @@ export enum MutationTypes { SET_CURRENT_PROJECTION = 'setCurrentProjection', SET_CURRENT_LOCATION = 'setCurrentLocation', SET_CURRENT_ZOOM = 'setCurrentZoom', - CLEAR_CURRENT_ZOOM = 'clearCurrentZoom', SET_PARSED_URL = 'setParsedUrl', CLEAR_PARSED_URL = 'clearParsedUrl', + CLEAR_CURRENT_MAP = 'clearCurrentMap', SET_FOLLOW_TARGET = 'setFollowTarget', SET_PAN_TARGET = 'setPanTarget', diff --git a/src/store/mutations.ts b/src/store/mutations.ts index dc5bfd6..6e9b5de 100644 --- a/src/store/mutations.ts +++ b/src/store/mutations.ts @@ -46,9 +46,7 @@ export type Mutations = { [MutationTypes.SET_WORLDS](state: S, worlds: Array): 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.CLEAR_WORLDS](state: S): void [MutationTypes.SET_WORLD_STATE](state: S, worldState: DynmapWorldState): void [MutationTypes.SET_UPDATE_TIMESTAMP](state: S, time: Date): void [MutationTypes.ADD_MARKER_SET_UPDATES](state: S, updates: Map): void @@ -70,9 +68,9 @@ export type Mutations = { [MutationTypes.SET_CURRENT_PROJECTION](state: S, payload: DynmapProjection): void [MutationTypes.SET_CURRENT_LOCATION](state: S, payload: Coordinate): void [MutationTypes.SET_CURRENT_ZOOM](state: S, payload: number): void - [MutationTypes.CLEAR_CURRENT_ZOOM](state: S): void [MutationTypes.SET_PARSED_URL](state: S, payload: DynmapParsedUrl): void [MutationTypes.CLEAR_PARSED_URL](state: S): void + [MutationTypes.CLEAR_CURRENT_MAP](state: S): void [MutationTypes.SET_FOLLOW_TARGET](state: S, payload: DynmapPlayer): void [MutationTypes.SET_PAN_TARGET](state: S, payload: DynmapPlayer): void [MutationTypes.CLEAR_FOLLOW_TARGET](state: S, a?: void): void @@ -145,31 +143,10 @@ export const mutations: MutationTree & Mutations = { } }, - //Sets the existing marker sets from the last marker fetch - [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); }, - [MutationTypes.CLEAR_WORLDS](state: State) { - console.log('??????'); - state.worlds.clear(); - state.maps.clear(); - - state.currentMap = undefined; - state.currentWorld = undefined; - state.followTarget = undefined; - state.panTarget = undefined; - - state.currentWorldState.timeOfDay = 0; - state.currentWorldState.raining = false; - state.currentWorldState.thundering = false; - }, - //Sets the current world state an update fetch [MutationTypes.SET_WORLD_STATE](state: State, worldState: DynmapWorldState) { state.currentWorldState = Object.assign(state.currentWorldState, worldState); @@ -383,10 +360,7 @@ export const mutations: MutationTree & Mutations = { [MutationTypes.CLEAR_PLAYERS](state: State) { state.followTarget = undefined; state.panTarget = undefined; - - for(const [key, player] of state.players) { - state.players.delete(key); - } + state.players.clear(); }, //Sets the currently active server @@ -437,15 +411,21 @@ export const mutations: MutationTree & Mutations = { state.currentZoom = payload; }, - [MutationTypes.CLEAR_CURRENT_ZOOM](state: State) { - state.currentZoom = 0; - }, - //Sets the result of parsing the current map url, if present and valid [MutationTypes.SET_PARSED_URL](state: State, payload: DynmapParsedUrl) { state.parsedUrl = payload; }, + //Clear the current map/world + [MutationTypes.CLEAR_CURRENT_MAP](state: State) { + state.markerSets.clear(); + state.pendingSetUpdates.clear(); + state.pendingTileUpdates = []; + + state.currentWorld = undefined; + state.currentMap = undefined; + }, + //Clear any existing parsed url [MutationTypes.CLEAR_PARSED_URL](state: State) { state.parsedUrl = {