From 07d81e86ea57418d1e3a083afd504d9d87c3ff01 Mon Sep 17 00:00:00 2001 From: James Lyne Date: Fri, 18 Dec 2020 14:32:58 +0000 Subject: [PATCH] Mutation documentation --- src/store/mutations.ts | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/store/mutations.ts b/src/store/mutations.ts index 9b467b0..55c841e 100644 --- a/src/store/mutations.ts +++ b/src/store/mutations.ts @@ -125,7 +125,7 @@ export const mutations: MutationTree & Mutations = { state.worlds.set(world.name, world); }, - //Sets the current world state from the last update fetch + //Sets the current world state an update fetch [MutationTypes.SET_WORLD_STATE](state: State, worldState: DynmapWorldState) { state.currentWorldState = Object.assign(state.currentWorldState, worldState); }, @@ -135,7 +135,7 @@ export const mutations: MutationTree & Mutations = { state.updateTimestamp = timestamp; }, - //Sets the timestamp of the last update fetch + //Adds markerset related updates from an update fetch to the pending updates list [MutationTypes.ADD_MARKER_SET_UPDATES](state: State, updates: Map) { for(const entry of updates) { if(!state.markerSets.has(entry[0])) { @@ -187,10 +187,12 @@ export const mutations: MutationTree & Mutations = { } }, + //Adds tile updates from an update fetch to the pending updates list [MutationTypes.ADD_TILE_UPDATES](state: State, updates: Array) { state.pendingTileUpdates = state.pendingTileUpdates.concat(updates); }, + //Adds chat messages from an update fetch to the chat history [MutationTypes.ADD_CHAT](state: State, chat: Array) { state.chat.unshift(...chat); }, @@ -288,6 +290,7 @@ export const mutations: MutationTree & Mutations = { } }, + //Sets the currently active map/world [MutationTypes.SET_CURRENT_MAP](state: State, {worldName, mapName}) { mapName = [worldName, mapName].join('_'); @@ -311,30 +314,37 @@ export const mutations: MutationTree & Mutations = { state.currentMap = state.maps.get(mapName); }, + //Sets the projection to use for coordinate conversion in the current map [MutationTypes.SET_CURRENT_PROJECTION](state: State, projection) { state.currentProjection = projection; }, + //Sets the current location the map is showing. This is called by the map itself, and calling elsewhere will not update the map. [MutationTypes.SET_CURRENT_LOCATION](state: State, payload: Coordinate) { state.currentLocation = payload; }, + //Sets the current zoom level of the map. This is called by the map itself, and calling elsewhere will not update the map. [MutationTypes.SET_CURRENT_ZOOM](state: State, payload: number) { state.currentZoom = payload; }, + //Sets the result of parsing the current map url, if present and valid [MutationTypes.SET_PARSED_URL](state: State, payload: DynmapParsedUrl) { state.parsedUrl = payload; }, + //Set the follow target, which the map will automatically pan to keep in view [MutationTypes.SET_FOLLOW_TARGET](state: State, player: DynmapPlayer) { state.followTarget = player; }, + //Set the pan target, which the map will immediately pan to once [MutationTypes.SET_PAN_TARGET](state: State, player: DynmapPlayer) { state.panTarget = player; }, + //Clear the follow target [MutationTypes.CLEAR_FOLLOW_TARGET](state: State) { state.followTarget = undefined; }