From ea62890ba0d704041ccab921815f484821e682e5 Mon Sep 17 00:00:00 2001 From: Inex Code Date: Thu, 21 Apr 2022 07:23:51 +0000 Subject: [PATCH] fix --- bin/server.dart | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/bin/server.dart b/bin/server.dart index abf17ef..3e966d3 100644 --- a/bin/server.dart +++ b/bin/server.dart @@ -82,13 +82,6 @@ Future _postOnMastodon(reqJson) async { var photos = attachments.where((attachment) => attachment['type'] == 'photo'); - // If there are more than four photos, move other photos to another array to be posted in the thread. - var otherPhotos = []; - if (photos.length > 4) { - otherPhotos = photos.skip(4).toList(); - photos = photos.take(4).toList(); - } - List photoUrls = []; for (final photo in photos) { @@ -102,6 +95,13 @@ Future _postOnMastodon(reqJson) async { photoUrls.add(photoPath); } + // If there are more than four photos, move other photos to another array to be posted in the thread. + List otherPhotos = []; + if (photoUrls.length > 4) { + otherPhotos = photos.skip(4).toList(); + photoUrls = photos.take(4).toList(); + } + // Post the post on Mastodon. // First we upload all photos with dio. // Then we post the post with the uploaded photos and the text. @@ -144,9 +144,9 @@ Future _postOnMastodon(reqJson) async { mediaIds = []; if (otherPhotos.length > 4) { otherPhotos = otherPhotos.skip(4).toList(); - photos = otherPhotos.take(4).toList(); + photoUrls = otherPhotos.take(4).toList(); } else { - photos = otherPhotos; + photoUrls = otherPhotos; otherPhotos = []; }