Avoid recreating tiles from scratch when refreshing Pl3xmap

This commit is contained in:
James Lyne 2021-08-16 03:33:28 +01:00
parent f316c0dd50
commit 552b289bb9
2 changed files with 23 additions and 7 deletions

View File

@ -43,15 +43,15 @@ export default defineComponent({
const store = useStore(),
active = computed(() => props.map === store.state.currentMap);
let redrawTimeout = 0,
let refreshTimeout = 0,
layer: LiveAtlasTileLayer;
const redraw = () => {
const refresh = () => {
if(active.value) {
layer._update();
layer.refresh();
}
redrawTimeout = setTimeout(redraw, props.map.tileUpdateInterval);
refreshTimeout = setTimeout(refresh, props.map.tileUpdateInterval);
};
if(store.state.currentServer?.type === 'dynmap') {
@ -81,14 +81,14 @@ export default defineComponent({
}
if(props.map.tileUpdateInterval) {
redrawTimeout = setTimeout(redraw, props.map.tileUpdateInterval);
refreshTimeout = setTimeout(refresh, props.map.tileUpdateInterval);
}
onUnmounted(() => {
disableLayer();
if(redrawTimeout) {
clearTimeout(redrawTimeout);
if(refreshTimeout) {
clearTimeout(refreshTimeout);
}
});
},

View File

@ -144,6 +144,22 @@ export abstract class LiveAtlasTileLayer extends TileLayer {
this.fetchTile(tile);
}
refresh() {
for (const i in this._tiles) {
if (!Object.prototype.hasOwnProperty.call(this._tiles, i)) {
continue;
}
const tile = this._tiles[i] as LiveAtlasTile;
if(tile.loaded) {
this.loadQueue.push(tile.el);
}
}
this.tickLoadQueue();
}
_abortLoading() {
let tile;