forked from MapComplete/MapComplete
UX: add progress bar to panoramax upload, fix hanging upload in case of multiple selected images, rm old log statements
This commit is contained in:
parent
767bd18234
commit
e33d448055
8 changed files with 35 additions and 22 deletions
|
@ -166,8 +166,9 @@ export class ImageUploadManager {
|
|||
console.log("Checking image upload queue and uploading if needed")
|
||||
this.uploadingAll = true
|
||||
try {
|
||||
for (const imageToUpload of queue) {
|
||||
await this.handleQueueItem(imageToUpload)
|
||||
while (queue.length > 0) {
|
||||
const currentItem = queue[0]
|
||||
await this.handleQueueItem(currentItem)
|
||||
}
|
||||
} catch (e) {
|
||||
console.error("Error while handling the queue:", e)
|
||||
|
@ -183,10 +184,12 @@ export class ImageUploadManager {
|
|||
* - indicates that the upload is busy
|
||||
* - Applies the action to the correct element
|
||||
* - indicates failure
|
||||
*
|
||||
* Modifies the queue: if the upload is successfull, deletes the item from the queue
|
||||
* @private
|
||||
*/
|
||||
private async handleQueueItem(args: ImageUploadArguments): Promise<void> {
|
||||
console.log("Handling queue item", args)
|
||||
console.log("Handling queue item", args.blob.name, args)
|
||||
if (!args) {
|
||||
return
|
||||
}
|
||||
|
@ -197,18 +200,22 @@ export class ImageUploadManager {
|
|||
while (attempts > 0 && result === undefined) {
|
||||
attempts--
|
||||
const doReport = attempts == 0
|
||||
result = await this.attemptSingleUpload(args, doReport)
|
||||
try {
|
||||
result = await this.attemptSingleUpload(args, doReport)
|
||||
} catch (e) {
|
||||
console.error("Uploading failed with error", e)
|
||||
}
|
||||
if (!result) {
|
||||
console.log("Upload attempt failed, attempts left:", attempts)
|
||||
}
|
||||
}
|
||||
this._isUploading.set(undefined)
|
||||
this._fails.set(this._fails.data.filter((a) => a !== args))
|
||||
if (result === undefined) {
|
||||
this._fails.data.push(args)
|
||||
this._fails.ping()
|
||||
return
|
||||
}
|
||||
this._fails.set(this._fails.data.filter((a) => a !== args))
|
||||
let properties: UIEventSource<Record<string, string>> = this._featureProperties.getStore(
|
||||
args.featureId
|
||||
)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue