From 0e3311351672143f63f1683a0edc5abf67baa84b Mon Sep 17 00:00:00 2001 From: Inex Code Date: Thu, 21 Apr 2022 07:12:15 +0000 Subject: [PATCH] fix asyncs --- bin/server.dart | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/bin/server.dart b/bin/server.dart index ab88a0c..24799e3 100644 --- a/bin/server.dart +++ b/bin/server.dart @@ -79,7 +79,9 @@ Future _postOnMastodon(reqJson) async { final photos = attachments.where((attachment) => attachment['type'] == 'photo'); - final photoUrls = photos.map((photo) async { + List photoUrls = []; + + for (final photo in photos) { final photoUrl = photo['photo']['sizes'].last['url']; // Generate a random filename. // Add the extension '.jpg'. @@ -87,8 +89,8 @@ Future _postOnMastodon(reqJson) async { final photoPath = '${Directory.systemTemp.path}/$photoFilename'; await dio.download(photoUrl, photoPath); - return photoPath; - }); + photoUrls.add(photoPath); + } // Post the post on Mastodon. // First we upload all photos with dio.