Skip to content

Commit

Permalink
Merge pull request #61 from PnEcrins/add-delay-between-tiles-download
Browse files Browse the repository at this point in the history
add delay between tiles downlaod
  • Loading branch information
TheoLechemia authored Jul 31, 2024
2 parents 72e7b64 + 45523c9 commit ebdd0e1
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions front-end/src/app/services/offline.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,15 +160,22 @@ export class OfflineService {
}

const tilesToDownload = [];
let delay = 0;
for (let index = 0; index < tilesToStore.length; index++) {
if (
!(await leafletOffline.default.getBlobByKey(tilesToStore[index].key))
) {
tilesToDownload.push(
leafletOffline.default
.downloadTile(tilesToStore[index].url)
.catch(() => null),
new Promise((resolve) =>
setTimeout(() => {
return leafletOffline.default
.downloadTile(tilesToStore[index].url)
.then((tile) => resolve(tile))
.catch(() => resolve(null));
}, delay),
),
);
delay += 20;
} else {
tilesToDownload.push(new Promise((resolve) => resolve(null)));
}
Expand Down

0 comments on commit ebdd0e1

Please sign in to comment.