Skip to content

Commit

Permalink
Merge pull request #1393 from placeAtlas/staging/code-minor
Browse files Browse the repository at this point in the history
  • Loading branch information
Hans5958 authored Jul 29, 2023
2 parents 0759d9f + c09f074 commit 6088930
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions web/_js/main/time.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,8 @@ const dispatchTimeUpdateEvent = (period = currentPeriod, variation = currentVari

async function updateBackground(newPeriod = currentPeriod, newVariation = currentVariation) {
abortController.abort()
abortController = new AbortController()
myAbortController = new AbortController()

Check notice on line 82 in web/_js/main/time.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

Implicitly declared global JavaScript variable

Variable myAbortController implicitly declared
abortController = myAbortController
currentUpdateIndex++
const myUpdateIndex = currentUpdateIndex
const variationConfig = variationsConfig[newVariation]
Expand Down Expand Up @@ -109,6 +110,7 @@ async function updateBackground(newPeriod = currentPeriod, newVariation = curren

layers.length = layerUrls.length
await Promise.all(layerUrls.map(async (url, i) => {
const imageBlob = await (await fetch(url, { signal: myAbortController.signal })).blob()
const imageLayer = new Image()
await new Promise(resolve => {
imageLayer.onload = () => {
Expand All @@ -117,10 +119,14 @@ async function updateBackground(newPeriod = currentPeriod, newVariation = curren
layers[i] = imageLayer
resolve()
}
imageLayer.src = url
imageLayer.src = URL.createObjectURL(imageBlob)
})
}))

if (myAbortController.signal.aborted || newPeriod !== currentPeriod || newVariation !== currentVariation) {
return
}

for (const imageLayer of layers) {
context.drawImage(imageLayer, 0, 0)
}
Expand Down

0 comments on commit 6088930

Please sign in to comment.