Remove useless returns from pop mutations

This commit is contained in:
James Lyne 2020-12-18 14:32:37 +00:00
parent 7fe660d491
commit 618b705732

View File

@ -19,16 +19,12 @@ import {MutationTypes} from "@/store/mutation-types";
import {State} from "@/store/state"; import {State} from "@/store/state";
import { import {
DynmapArea, DynmapArea,
DynmapAreaUpdate,
DynmapCircle, DynmapCircle,
DynmapCircleUpdate,
DynmapComponentConfig, DynmapComponentConfig,
DynmapLine, DynmapLine, Coordinate,
DynmapLineUpdate, Coordinate,
DynmapMarker, DynmapMarker,
DynmapMarkerSet, DynmapMarkerSet,
DynmapMarkerSetUpdates, DynmapMarkerSetUpdates,
DynmapMarkerUpdate,
DynmapMessageConfig, DynmapMessageConfig,
DynmapPlayer, DynmapPlayer,
DynmapServerConfig, DynmapTileUpdate, DynmapServerConfig, DynmapTileUpdate,
@ -55,11 +51,11 @@ export type Mutations<S = State> = {
[MutationTypes.ADD_TILE_UPDATES](state: S, updates: Array<DynmapTileUpdate>): void [MutationTypes.ADD_TILE_UPDATES](state: S, updates: Array<DynmapTileUpdate>): void
[MutationTypes.ADD_CHAT](state: State, chat: Array<DynmapChat>): void [MutationTypes.ADD_CHAT](state: State, chat: Array<DynmapChat>): void
[MutationTypes.POP_MARKER_UPDATES](state: S, payload: {markerSet: string, amount: number}): Array<DynmapMarkerUpdate> [MutationTypes.POP_MARKER_UPDATES](state: S, payload: {markerSet: string, amount: number}): void
[MutationTypes.POP_AREA_UPDATES](state: S, payload: {markerSet: string, amount: number}): Array<DynmapAreaUpdate> [MutationTypes.POP_AREA_UPDATES](state: S, payload: {markerSet: string, amount: number}): void
[MutationTypes.POP_CIRCLE_UPDATES](state: S, payload: {markerSet: string, amount: number}): Array<DynmapCircleUpdate> [MutationTypes.POP_CIRCLE_UPDATES](state: S, payload: {markerSet: string, amount: number}): void
[MutationTypes.POP_LINE_UPDATES](state: S, payload: {markerSet: string, amount: number}): Array<DynmapLineUpdate> [MutationTypes.POP_LINE_UPDATES](state: S, payload: {markerSet: string, amount: number}): void
[MutationTypes.POP_TILE_UPDATES](state: S, amount: number): Array<DynmapTileUpdate> [MutationTypes.POP_TILE_UPDATES](state: S, amount: number): void
[MutationTypes.INCREMENT_REQUEST_ID](state: S): void [MutationTypes.INCREMENT_REQUEST_ID](state: S): void
[MutationTypes.SET_PLAYERS_ASYNC](state: S, players: Set<DynmapPlayer>): Set<DynmapPlayer> [MutationTypes.SET_PLAYERS_ASYNC](state: S, players: Set<DynmapPlayer>): Set<DynmapPlayer>
@ -199,44 +195,49 @@ export const mutations: MutationTree<State> & Mutations = {
state.chat.unshift(...chat); state.chat.unshift(...chat);
}, },
[MutationTypes.POP_MARKER_UPDATES](state: State, {markerSet, amount}): Array<DynmapMarkerUpdate> { //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)) { if(!state.markerSets.has(markerSet)) {
console.log(`Marker set ${markerSet} doesn't exist`); 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<DynmapAreaUpdate> { //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)) { if(!state.markerSets.has(markerSet)) {
console.log(`Marker set ${markerSet} doesn't exist`); 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<DynmapCircleUpdate> { //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)) { if(!state.markerSets.has(markerSet)) {
console.log(`Marker set ${markerSet} doesn't exist`); 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<DynmapLineUpdate> { //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)) { if(!state.markerSets.has(markerSet)) {
console.log(`Marker set ${markerSet} doesn't exist`); 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<DynmapTileUpdate> { //Pops the specified number of tile updates from the pending updates list
return state.pendingTileUpdates.splice(0, amount); [MutationTypes.POP_TILE_UPDATES](state: State, amount: number) {
state.pendingTileUpdates.splice(0, amount);
}, },
//Increments the request id for the next update fetch //Increments the request id for the next update fetch