async await??
This commit is contained in:
parent
473828f498
commit
b6b58e8895
|
@ -103,12 +103,14 @@ Future<void> _postOnMastodon(reqJson) async {
|
|||
if (photos.isEmpty) {
|
||||
await dio.post('$instanceUrl/api/v1/statuses',
|
||||
data: {'status': postText},
|
||||
options: dio_lib.Options(headers: {'Authorization': 'Bearer $authToken'}));
|
||||
options:
|
||||
dio_lib.Options(headers: {'Authorization': 'Bearer $authToken'}));
|
||||
} else {
|
||||
final mediaResponses = await Future.wait(
|
||||
photoUrls.map((photoUrl) async => dio.post('$instanceUrl/api/v1/media',
|
||||
final mediaResponses = await photoUrls.map((photoUrl) async => await dio.post(
|
||||
'$instanceUrl/api/v1/media',
|
||||
data: dio_lib.FormData.fromMap({'file': File(photoUrl)}),
|
||||
options: dio_lib.Options(headers: {'Authorization': 'Bearer $authToken'}))));
|
||||
options:
|
||||
dio_lib.Options(headers: {'Authorization': 'Bearer $authToken'})));
|
||||
|
||||
final mediaIds = mediaResponses.map((mediaResponse) {
|
||||
final mediaId = mediaResponse.data['id'];
|
||||
|
@ -116,11 +118,9 @@ Future<void> _postOnMastodon(reqJson) async {
|
|||
}).toList();
|
||||
|
||||
await dio.post('$instanceUrl/api/v1/statuses',
|
||||
data: {
|
||||
'status': postText,
|
||||
'media_ids': mediaIds
|
||||
},
|
||||
options: dio_lib.Options(headers: {'Authorization': 'Bearer $authToken'}));
|
||||
data: {'status': postText, 'media_ids': mediaIds},
|
||||
options:
|
||||
dio_lib.Options(headers: {'Authorization': 'Bearer $authToken'}));
|
||||
|
||||
await Future.wait(photoUrls.map((photoUrl) => File(photoUrl).delete()));
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue