diff --git a/src/store/mutations.ts b/src/store/mutations.ts index 0ac5f02..9b467b0 100644 --- a/src/store/mutations.ts +++ b/src/store/mutations.ts @@ -19,16 +19,12 @@ import {MutationTypes} from "@/store/mutation-types"; import {State} from "@/store/state"; import { DynmapArea, - DynmapAreaUpdate, DynmapCircle, - DynmapCircleUpdate, DynmapComponentConfig, - DynmapLine, - DynmapLineUpdate, Coordinate, + DynmapLine, Coordinate, DynmapMarker, DynmapMarkerSet, DynmapMarkerSetUpdates, - DynmapMarkerUpdate, DynmapMessageConfig, DynmapPlayer, DynmapServerConfig, DynmapTileUpdate, @@ -55,11 +51,11 @@ export type Mutations = { [MutationTypes.ADD_TILE_UPDATES](state: S, updates: Array): void [MutationTypes.ADD_CHAT](state: State, chat: Array): void - [MutationTypes.POP_MARKER_UPDATES](state: S, payload: {markerSet: string, amount: number}): Array - [MutationTypes.POP_AREA_UPDATES](state: S, payload: {markerSet: string, amount: number}): Array - [MutationTypes.POP_CIRCLE_UPDATES](state: S, payload: {markerSet: string, amount: number}): Array - [MutationTypes.POP_LINE_UPDATES](state: S, payload: {markerSet: string, amount: number}): Array - [MutationTypes.POP_TILE_UPDATES](state: S, amount: number): Array + [MutationTypes.POP_MARKER_UPDATES](state: S, payload: {markerSet: string, amount: number}): void + [MutationTypes.POP_AREA_UPDATES](state: S, payload: {markerSet: string, amount: number}): void + [MutationTypes.POP_CIRCLE_UPDATES](state: S, payload: {markerSet: string, amount: number}): void + [MutationTypes.POP_LINE_UPDATES](state: S, payload: {markerSet: string, amount: number}): void + [MutationTypes.POP_TILE_UPDATES](state: S, amount: number): void [MutationTypes.INCREMENT_REQUEST_ID](state: S): void [MutationTypes.SET_PLAYERS_ASYNC](state: S, players: Set): Set @@ -199,44 +195,49 @@ export const mutations: MutationTree & Mutations = { state.chat.unshift(...chat); }, - [MutationTypes.POP_MARKER_UPDATES](state: State, {markerSet, amount}): Array { + //Pops the specified number of marker updates from the pending updates list + [MutationTypes.POP_MARKER_UPDATES](state: State, {markerSet, amount}) { if(!state.markerSets.has(markerSet)) { console.log(`Marker set ${markerSet} doesn't exist`); - return []; + return; } - return state.pendingSetUpdates.get(markerSet)!.markerUpdates.splice(0, amount); + state.pendingSetUpdates.get(markerSet)!.markerUpdates.splice(0, amount); }, - [MutationTypes.POP_AREA_UPDATES](state: State, {markerSet, amount}): Array { + //Pops the specified number of area updates from the pending updates list + [MutationTypes.POP_AREA_UPDATES](state: State, {markerSet, amount}) { if(!state.markerSets.has(markerSet)) { console.log(`Marker set ${markerSet} doesn't exist`); - return []; + return; } - return state.pendingSetUpdates.get(markerSet)!.areaUpdates.splice(0, amount); + state.pendingSetUpdates.get(markerSet)!.areaUpdates.splice(0, amount); }, - [MutationTypes.POP_CIRCLE_UPDATES](state: State, {markerSet, amount}): Array { + //Pops the specified number of circle updates from the pending updates list + [MutationTypes.POP_CIRCLE_UPDATES](state: State, {markerSet, amount}) { if(!state.markerSets.has(markerSet)) { console.log(`Marker set ${markerSet} doesn't exist`); - return []; + return; } - return state.pendingSetUpdates.get(markerSet)!.circleUpdates.splice(0, amount); + state.pendingSetUpdates.get(markerSet)!.circleUpdates.splice(0, amount); }, - [MutationTypes.POP_LINE_UPDATES](state: State, {markerSet, amount}): Array { + //Pops the specified number of line updates from the pending updates list + [MutationTypes.POP_LINE_UPDATES](state: State, {markerSet, amount}) { if(!state.markerSets.has(markerSet)) { console.log(`Marker set ${markerSet} doesn't exist`); - return []; + return; } - return state.pendingSetUpdates.get(markerSet)!.lineUpdates.splice(0, amount); + state.pendingSetUpdates.get(markerSet)!.lineUpdates.splice(0, amount); }, - [MutationTypes.POP_TILE_UPDATES](state: State, amount: number): Array { - return state.pendingTileUpdates.splice(0, amount); + //Pops the specified number of tile updates from the pending updates list + [MutationTypes.POP_TILE_UPDATES](state: State, amount: number) { + state.pendingTileUpdates.splice(0, amount); }, //Increments the request id for the next update fetch