Properly wire 'async' through the uploader

This commit is contained in:
Pieter Vander Vennet 2022-09-02 12:39:40 +02:00
parent 89b9cb4b47
commit cbf5c5a748
4 changed files with 19 additions and 18 deletions

View file

@ -36,7 +36,7 @@ export class ImageUploadFlow extends Toggle {
perId.set(id, new UIEventSource<number>(0))
}
const uploadedCount = perId.get(id)
const uploader = new ImgurUploader(url => {
const uploader = new ImgurUploader(async url => {
// A file was uploaded - we add it to the tags of the object
const tags = tagsSource.data
@ -48,17 +48,18 @@ export class ImageUploadFlow extends Toggle {
}
key = imagePrefix + ":" + freeIndex;
}
console.log("Adding image:" + key, url);
uploadedCount.data++
uploadedCount.ping()
Promise.resolve(state.changes
await state.changes
.applyAction(new ChangeTagAction(
tags.id, new Tag(key, url), tagsSource.data,
{
changeType: "add-image",
theme: state.layoutToUse.id
}
)))
))
console.log("Adding image:" + key, url);
uploadedCount.data++
uploadedCount.ping()
})
const licensePicker = new LicensePicker(state)

View file

@ -1062,9 +1062,9 @@ export default class SpecialVisualizations {
const t = Translations.t.notes;
const id = tags.data[args[0] ?? "id"]
const uploader = new ImgurUploader(url => {
const uploader = new ImgurUploader(async url => {
isUploading.setData(false)
state.osmConnection.addCommentToNote(id, url)
await state.osmConnection.addCommentToNote(id, url)
NoteCommentElement.addCommentTo(url, tags, state)
})