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

@ -7,9 +7,9 @@ export default class ImgurUploader {
public readonly failed: UIEventSource<string[]> = new UIEventSource<string[]>([]);
public readonly success: UIEventSource<string[]> = new UIEventSource<string[]>([]);
public maxFileSizeInMegabytes = 10;
private readonly _handleSuccessUrl: (string) => void;
private readonly _handleSuccessUrl: (string) => Promise<void>;
constructor(handleSuccessUrl: (string) => void) {
constructor(handleSuccessUrl: (string) => Promise<void>) {
this._handleSuccessUrl = handleSuccessUrl;
}
@ -24,11 +24,11 @@ export default class ImgurUploader {
Imgur.uploadMultiple(title,
description,
files,
function (url) {
async function (url) {
console.log("File saved at", url);
self.success.data.push(url)
self.success.ping();
self._handleSuccessUrl(url);
await self._handleSuccessUrl(url);
},
function () {
console.log("All uploads completed");