diff --git a/src/api.ts b/src/api.ts index 689de0d..59e88e2 100644 --- a/src/api.ts +++ b/src/api.ts @@ -646,12 +646,18 @@ const validateDynmapConfiguration = (config: DynmapUrlConfig): Map { @@ -683,7 +692,13 @@ export default { }, async getConfiguration(): Promise { - const response = await fetchJSON(useStore().getters.serverConfig.dynmap.configuration); + if(configurationAbort) { + configurationAbort.abort(); + } + + configurationAbort = new AbortController(); + + const response = await fetchJSON(useStore().getters.serverConfig.dynmap.configuration, configurationAbort.signal); if (response.error === 'login-required') { throw new Error("Login required"); @@ -705,7 +720,13 @@ export default { url = url.replace('{world}', world); url = url.replace('{timestamp}', timestamp.toString()); - const response = await fetchJSON(url); + if(updateAbort) { + updateAbort.abort(); + } + + updateAbort = new AbortController(); + + const response = await fetchJSON(url, updateAbort.signal); const players: Set = new Set(); (response.players || []).forEach((player: any) => { @@ -762,7 +783,13 @@ export default { async getMarkerSets(world: string): Promise> { const url = `${useStore().getters.serverConfig.dynmap.markers}_markers_/marker_${world}.json`; - const response = await fetchJSON(url); + if(markersAbort) { + markersAbort.abort(); + } + + markersAbort = new AbortController(); + + const response = await fetchJSON(url, markersAbort.signal); const sets: Map = new Map(); response.sets = response.sets || {};