fix asyncs

This commit is contained in:
Inex Code 2022-04-21 07:12:15 +00:00
parent 449640699f
commit 0e33113516
1 changed files with 5 additions and 3 deletions

View File

@ -79,7 +79,9 @@ Future<void> _postOnMastodon(reqJson) async {
final photos = final photos =
attachments.where((attachment) => attachment['type'] == 'photo'); attachments.where((attachment) => attachment['type'] == 'photo');
final photoUrls = photos.map((photo) async { List<String> photoUrls = [];
for (final photo in photos) {
final photoUrl = photo['photo']['sizes'].last['url']; final photoUrl = photo['photo']['sizes'].last['url'];
// Generate a random filename. // Generate a random filename.
// Add the extension '.jpg'. // Add the extension '.jpg'.
@ -87,8 +89,8 @@ Future<void> _postOnMastodon(reqJson) async {
final photoPath = final photoPath =
'${Directory.systemTemp.path}/$photoFilename'; '${Directory.systemTemp.path}/$photoFilename';
await dio.download(photoUrl, photoPath); await dio.download(photoUrl, photoPath);
return photoPath; photoUrls.add(photoPath);
}); }
// Post the post on Mastodon. // Post the post on Mastodon.
// First we upload all photos with dio. // First we upload all photos with dio.