Improve server switch process
This commit is contained in:
parent
97fed3fed2
commit
f3913ef96b
@ -54,7 +54,7 @@ export default defineComponent({
|
|||||||
loadConfiguration = () => {
|
loadConfiguration = () => {
|
||||||
return store.dispatch(ActionTypes.LOAD_CONFIGURATION, undefined).then(() => {
|
return store.dispatch(ActionTypes.LOAD_CONFIGURATION, undefined).then(() => {
|
||||||
startUpdates();
|
startUpdates();
|
||||||
window.hideSplash();
|
requestAnimationFrame(window.hideSplash);
|
||||||
}).catch(e => {
|
}).catch(e => {
|
||||||
console.error('Failed to load server configuration: ', e);
|
console.error('Failed to load server configuration: ', e);
|
||||||
window.showSplashError(e, false, ++configAttempts.value);
|
window.showSplashError(e, false, ++configAttempts.value);
|
||||||
@ -117,7 +117,6 @@ export default defineComponent({
|
|||||||
stopUpdates();
|
stopUpdates();
|
||||||
window.history.replaceState({}, '', newServer);
|
window.history.replaceState({}, '', newServer);
|
||||||
store.commit(MutationTypes.CLEAR_PARSED_URL, undefined);
|
store.commit(MutationTypes.CLEAR_PARSED_URL, undefined);
|
||||||
store.commit(MutationTypes.CLEAR_CURRENT_ZOOM, undefined);
|
|
||||||
|
|
||||||
loadConfiguration();
|
loadConfiguration();
|
||||||
});
|
});
|
||||||
|
@ -226,7 +226,7 @@ export default defineComponent({
|
|||||||
this.updateChatBalloon();
|
this.updateChatBalloon();
|
||||||
},
|
},
|
||||||
currentWorld(newValue) {
|
currentWorld(newValue) {
|
||||||
if(newValue.name === this.player.location.world) {
|
if(newValue && newValue.name === this.player.location.world) {
|
||||||
this.enableLayer();
|
this.enableLayer();
|
||||||
} else if(this.markerVisible) {
|
} else if(this.markerVisible) {
|
||||||
this.disableLayer();
|
this.disableLayer();
|
||||||
|
@ -41,9 +41,7 @@ window.showSplash = function() {
|
|||||||
splash.hidden = false;
|
splash.hidden = false;
|
||||||
|
|
||||||
requestAnimationFrame(function() {
|
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);
|
store.commit(MutationTypes.SET_CURRENT_SERVER, config.keys().next().value);
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log(store.state.currentServer);
|
|
||||||
|
|
||||||
const app = createApp(App).use(store);
|
const app = createApp(App).use(store);
|
||||||
|
|
||||||
// app.config.performance = true;
|
// app.config.performance = true;
|
||||||
|
@ -78,11 +78,11 @@ export interface Actions {
|
|||||||
|
|
||||||
export const actions: ActionTree<State, State> & Actions = {
|
export const actions: ActionTree<State, State> & Actions = {
|
||||||
[ActionTypes.LOAD_CONFIGURATION]({commit, state}): Promise<DynmapConfigurationResponse> {
|
[ActionTypes.LOAD_CONFIGURATION]({commit, state}): Promise<DynmapConfigurationResponse> {
|
||||||
commit(MutationTypes.CLEAR_MARKER_SETS, undefined);
|
//Cleanup in case we are switching servers
|
||||||
commit(MutationTypes.CLEAR_PLAYERS, undefined);
|
commit(MutationTypes.CLEAR_PLAYERS, undefined);
|
||||||
|
commit(MutationTypes.CLEAR_CURRENT_MAP, undefined);
|
||||||
|
|
||||||
return API.getConfiguration().then(config => {
|
return API.getConfiguration().then(config => {
|
||||||
commit(MutationTypes.CLEAR_WORLDS, undefined);
|
|
||||||
commit(MutationTypes.SET_CONFIGURATION, config.config);
|
commit(MutationTypes.SET_CONFIGURATION, config.config);
|
||||||
commit(MutationTypes.SET_MESSAGES, config.messages);
|
commit(MutationTypes.SET_MESSAGES, config.messages);
|
||||||
commit(MutationTypes.SET_WORLDS, config.worlds);
|
commit(MutationTypes.SET_WORLDS, config.worlds);
|
||||||
|
@ -21,9 +21,7 @@ export enum MutationTypes {
|
|||||||
SET_WORLDS = 'setWorlds',
|
SET_WORLDS = 'setWorlds',
|
||||||
SET_COMPONENTS = 'setComponents',
|
SET_COMPONENTS = 'setComponents',
|
||||||
SET_MARKER_SETS = 'setMarkerSets',
|
SET_MARKER_SETS = 'setMarkerSets',
|
||||||
CLEAR_MARKER_SETS = 'clearMarkerSets',
|
|
||||||
ADD_WORLD = 'addWorld',
|
ADD_WORLD = 'addWorld',
|
||||||
CLEAR_WORLDS = 'clearWorlds',
|
|
||||||
SET_WORLD_STATE = 'setWorldState',
|
SET_WORLD_STATE = 'setWorldState',
|
||||||
SET_UPDATE_TIMESTAMP = 'setUpdateTimestamp',
|
SET_UPDATE_TIMESTAMP = 'setUpdateTimestamp',
|
||||||
ADD_MARKER_SET_UPDATES = 'addMarkerSetUpdates',
|
ADD_MARKER_SET_UPDATES = 'addMarkerSetUpdates',
|
||||||
@ -44,9 +42,9 @@ export enum MutationTypes {
|
|||||||
SET_CURRENT_PROJECTION = 'setCurrentProjection',
|
SET_CURRENT_PROJECTION = 'setCurrentProjection',
|
||||||
SET_CURRENT_LOCATION = 'setCurrentLocation',
|
SET_CURRENT_LOCATION = 'setCurrentLocation',
|
||||||
SET_CURRENT_ZOOM = 'setCurrentZoom',
|
SET_CURRENT_ZOOM = 'setCurrentZoom',
|
||||||
CLEAR_CURRENT_ZOOM = 'clearCurrentZoom',
|
|
||||||
SET_PARSED_URL = 'setParsedUrl',
|
SET_PARSED_URL = 'setParsedUrl',
|
||||||
CLEAR_PARSED_URL = 'clearParsedUrl',
|
CLEAR_PARSED_URL = 'clearParsedUrl',
|
||||||
|
CLEAR_CURRENT_MAP = 'clearCurrentMap',
|
||||||
|
|
||||||
SET_FOLLOW_TARGET = 'setFollowTarget',
|
SET_FOLLOW_TARGET = 'setFollowTarget',
|
||||||
SET_PAN_TARGET = 'setPanTarget',
|
SET_PAN_TARGET = 'setPanTarget',
|
||||||
|
@ -46,9 +46,7 @@ export type Mutations<S = State> = {
|
|||||||
[MutationTypes.SET_WORLDS](state: S, worlds: Array<DynmapWorld>): void
|
[MutationTypes.SET_WORLDS](state: S, worlds: Array<DynmapWorld>): void
|
||||||
[MutationTypes.SET_COMPONENTS](state: S, worlds: DynmapComponentConfig): void
|
[MutationTypes.SET_COMPONENTS](state: S, worlds: DynmapComponentConfig): void
|
||||||
[MutationTypes.SET_MARKER_SETS](state: S, worlds: Map<string, DynmapMarkerSet>): void
|
[MutationTypes.SET_MARKER_SETS](state: S, worlds: Map<string, DynmapMarkerSet>): void
|
||||||
[MutationTypes.CLEAR_MARKER_SETS](state: S): void
|
|
||||||
[MutationTypes.ADD_WORLD](state: S, world: DynmapWorld): 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_WORLD_STATE](state: S, worldState: DynmapWorldState): void
|
||||||
[MutationTypes.SET_UPDATE_TIMESTAMP](state: S, time: Date): void
|
[MutationTypes.SET_UPDATE_TIMESTAMP](state: S, time: Date): void
|
||||||
[MutationTypes.ADD_MARKER_SET_UPDATES](state: S, updates: Map<string, DynmapMarkerSetUpdates>): void
|
[MutationTypes.ADD_MARKER_SET_UPDATES](state: S, updates: Map<string, DynmapMarkerSetUpdates>): void
|
||||||
@ -70,9 +68,9 @@ export type Mutations<S = State> = {
|
|||||||
[MutationTypes.SET_CURRENT_PROJECTION](state: S, payload: DynmapProjection): void
|
[MutationTypes.SET_CURRENT_PROJECTION](state: S, payload: DynmapProjection): void
|
||||||
[MutationTypes.SET_CURRENT_LOCATION](state: S, payload: Coordinate): void
|
[MutationTypes.SET_CURRENT_LOCATION](state: S, payload: Coordinate): void
|
||||||
[MutationTypes.SET_CURRENT_ZOOM](state: S, payload: number): 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.SET_PARSED_URL](state: S, payload: DynmapParsedUrl): void
|
||||||
[MutationTypes.CLEAR_PARSED_URL](state: S): 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_FOLLOW_TARGET](state: S, payload: DynmapPlayer): void
|
||||||
[MutationTypes.SET_PAN_TARGET](state: S, payload: DynmapPlayer): void
|
[MutationTypes.SET_PAN_TARGET](state: S, payload: DynmapPlayer): void
|
||||||
[MutationTypes.CLEAR_FOLLOW_TARGET](state: S, a?: void): void
|
[MutationTypes.CLEAR_FOLLOW_TARGET](state: S, a?: void): void
|
||||||
@ -145,31 +143,10 @@ export const mutations: MutationTree<State> & 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) {
|
[MutationTypes.ADD_WORLD](state: State, world: DynmapWorld) {
|
||||||
state.worlds.set(world.name, world);
|
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
|
//Sets the current world state an update fetch
|
||||||
[MutationTypes.SET_WORLD_STATE](state: State, worldState: DynmapWorldState) {
|
[MutationTypes.SET_WORLD_STATE](state: State, worldState: DynmapWorldState) {
|
||||||
state.currentWorldState = Object.assign(state.currentWorldState, worldState);
|
state.currentWorldState = Object.assign(state.currentWorldState, worldState);
|
||||||
@ -383,10 +360,7 @@ export const mutations: MutationTree<State> & Mutations = {
|
|||||||
[MutationTypes.CLEAR_PLAYERS](state: State) {
|
[MutationTypes.CLEAR_PLAYERS](state: State) {
|
||||||
state.followTarget = undefined;
|
state.followTarget = undefined;
|
||||||
state.panTarget = undefined;
|
state.panTarget = undefined;
|
||||||
|
state.players.clear();
|
||||||
for(const [key, player] of state.players) {
|
|
||||||
state.players.delete(key);
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
|
|
||||||
//Sets the currently active server
|
//Sets the currently active server
|
||||||
@ -437,15 +411,21 @@ export const mutations: MutationTree<State> & Mutations = {
|
|||||||
state.currentZoom = payload;
|
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
|
//Sets the result of parsing the current map url, if present and valid
|
||||||
[MutationTypes.SET_PARSED_URL](state: State, payload: DynmapParsedUrl) {
|
[MutationTypes.SET_PARSED_URL](state: State, payload: DynmapParsedUrl) {
|
||||||
state.parsedUrl = payload;
|
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
|
//Clear any existing parsed url
|
||||||
[MutationTypes.CLEAR_PARSED_URL](state: State) {
|
[MutationTypes.CLEAR_PARSED_URL](state: State) {
|
||||||
state.parsedUrl = {
|
state.parsedUrl = {
|
||||||
|
Loading…
Reference in New Issue
Block a user