Use async/await in more places

This commit is contained in:
James Lyne 2021-05-18 18:23:10 +01:00
parent a6ae811660
commit a3aa04c2dd
5 changed files with 112 additions and 112 deletions

View File

@ -73,19 +73,19 @@ export default defineComponent({
} }
}, },
handlePendingUpdates = () => { handlePendingUpdates = async () => {
useStore().dispatch(ActionTypes.POP_TILE_UPDATES, 10).then(updates => { const updates = await useStore().dispatch(ActionTypes.POP_TILE_UPDATES, 10);
for(const update of updates) {
layer.updateNamedTile(update.name, update.timestamp);
}
if(pendingUpdates.value) { for(const update of updates) {
// eslint-disable-next-line no-unused-vars layer.updateNamedTile(update.name, update.timestamp);
updateFrame = requestAnimationFrame(() => handlePendingUpdates()); }
} else {
updateFrame = 0; if(pendingUpdates.value) {
} // eslint-disable-next-line no-unused-vars
}); updateFrame = requestAnimationFrame(() => handlePendingUpdates());
} else {
updateFrame = 0;
}
}; };
watch(active, (newValue) => newValue ? enableLayer() : disableLayer()); watch(active, (newValue) => newValue ? enableLayer() : disableLayer());

View File

@ -71,34 +71,34 @@ export default defineComponent({
layers.delete(id); layers.delete(id);
}, },
handlePendingUpdates = () => { handlePendingUpdates = async () => {
useStore().dispatch(ActionTypes.POP_AREA_UPDATES, { const updates = await useStore().dispatch(ActionTypes.POP_AREA_UPDATES, {
markerSet: props.set.id, markerSet: props.set.id,
amount: 10, amount: 10,
}).then(updates => {
const converter = getPointConverter();
for(const update of updates) {
if(update.removed) {
deleteArea(update.id);
} else {
const layer = updateArea(layers.get(update.id), update.payload as DynmapArea, converter)
if(!layers.has(update.id)) {
props.layerGroup.addLayer(layer);
}
layers.set(update.id, layer);
}
}
if(pendingUpdates.value) {
// eslint-disable-next-line no-unused-vars
updateFrame = requestAnimationFrame(() => handlePendingUpdates());
} else {
updateFrame = 0;
}
}); });
const converter = getPointConverter();
for(const update of updates) {
if(update.removed) {
deleteArea(update.id);
} else {
const layer = updateArea(layers.get(update.id), update.payload as DynmapArea, converter)
if(!layers.has(update.id)) {
props.layerGroup.addLayer(layer);
}
layers.set(update.id, layer);
}
}
if(pendingUpdates.value) {
// eslint-disable-next-line no-unused-vars
updateFrame = requestAnimationFrame(() => handlePendingUpdates());
} else {
updateFrame = 0;
}
}; };
//FIXME: Prevent unnecessary repositioning when changing worlds //FIXME: Prevent unnecessary repositioning when changing worlds

View File

@ -71,34 +71,34 @@ export default defineComponent({
layers.delete(id); layers.delete(id);
}, },
handlePendingUpdates = () => { handlePendingUpdates = async () => {
useStore().dispatch(ActionTypes.POP_CIRCLE_UPDATES, { const updates = await useStore().dispatch(ActionTypes.POP_CIRCLE_UPDATES, {
markerSet: props.set.id, markerSet: props.set.id,
amount: 10, amount: 10,
}).then(updates => {
const converter = getPointConverter();
for(const update of updates) {
if(update.removed) {
deleteCircle(update.id);
} else {
const layer = updateCircle(layers.get(update.id), update.payload as DynmapCircle, converter)
if(!layers.has(update.id)) {
props.layerGroup.addLayer(layer);
}
layers.set(update.id, layer);
}
}
if(pendingUpdates.value) {
// eslint-disable-next-line no-unused-vars
updateFrame = requestAnimationFrame(() => handlePendingUpdates());
} else {
updateFrame = 0;
}
}); });
const converter = getPointConverter();
for(const update of updates) {
if(update.removed) {
deleteCircle(update.id);
} else {
const layer = updateCircle(layers.get(update.id), update.payload as DynmapCircle, converter)
if(!layers.has(update.id)) {
props.layerGroup.addLayer(layer);
}
layers.set(update.id, layer);
}
}
if(pendingUpdates.value) {
// eslint-disable-next-line no-unused-vars
updateFrame = requestAnimationFrame(() => handlePendingUpdates());
} else {
updateFrame = 0;
}
}; };
//FIXME: Prevent unnecessary repositioning when changing worlds //FIXME: Prevent unnecessary repositioning when changing worlds

View File

@ -70,34 +70,34 @@ export default defineComponent({
layers.delete(id); layers.delete(id);
}, },
handlePendingUpdates = () => { handlePendingUpdates = async () => {
useStore().dispatch(ActionTypes.POP_LINE_UPDATES, { const updates = await useStore().dispatch(ActionTypes.POP_LINE_UPDATES, {
markerSet: props.set.id, markerSet: props.set.id,
amount: 10, amount: 10,
}).then(updates => {
const converter = getPointConverter();
for(const update of updates) {
if(update.removed) {
deleteLine(update.id);
} else {
const layer = updateLine(layers.get(update.id), update.payload as DynmapLine, converter)
if(!layers.has(update.id)) {
props.layerGroup.addLayer(layer);
}
layers.set(update.id, layer);
}
}
if(pendingUpdates.value) {
// eslint-disable-next-line no-unused-vars
updateFrame = requestAnimationFrame(() => handlePendingUpdates());
} else {
updateFrame = 0;
}
}); });
const converter = getPointConverter();
for(const update of updates) {
if(update.removed) {
deleteLine(update.id);
} else {
const layer = updateLine(layers.get(update.id), update.payload as DynmapLine, converter)
if(!layers.has(update.id)) {
props.layerGroup.addLayer(layer);
}
layers.set(update.id, layer);
}
}
if(pendingUpdates.value) {
// eslint-disable-next-line no-unused-vars
updateFrame = requestAnimationFrame(() => handlePendingUpdates());
} else {
updateFrame = 0;
}
}; };
//FIXME: Prevent unnecessary repositioning when changing worlds //FIXME: Prevent unnecessary repositioning when changing worlds

View File

@ -69,34 +69,34 @@ export default defineComponent({
layers.delete(id); layers.delete(id);
}, },
handlePendingUpdates = () => { handlePendingUpdates = async () => {
useStore().dispatch(ActionTypes.POP_MARKER_UPDATES, { const updates = await useStore().dispatch(ActionTypes.POP_MARKER_UPDATES, {
markerSet: props.set.id, markerSet: props.set.id,
amount: 10, amount: 10,
}).then(updates => {
const projection = currentProjection.value;
for(const update of updates) {
if(update.removed) {
deleteMarker(update.id);
} else {
const layer = updateMarker(layers.get(update.id), update.payload as DynmapMarker, projection);
if(!layers.has(update.id)) {
props.layerGroup.addLayer(layer);
}
layers.set(update.id, layer);
}
}
if(pendingUpdates.value) {
// eslint-disable-next-line no-unused-vars
updateFrame = requestAnimationFrame(() => handlePendingUpdates());
} else {
updateFrame = 0;
}
}); });
const projection = currentProjection.value;
for(const update of updates) {
if(update.removed) {
deleteMarker(update.id);
} else {
const layer = updateMarker(layers.get(update.id), update.payload as DynmapMarker, projection);
if(!layers.has(update.id)) {
props.layerGroup.addLayer(layer);
}
layers.set(update.id, layer);
}
}
if(pendingUpdates.value) {
// eslint-disable-next-line no-unused-vars
updateFrame = requestAnimationFrame(() => handlePendingUpdates());
} else {
updateFrame = 0;
}
}; };
//FIXME: Prevent unnecessary repositioning when changing worlds //FIXME: Prevent unnecessary repositioning when changing worlds