From d2221d539c9d183390678af7d02c63d525a3970e Mon Sep 17 00:00:00 2001 From: Nicolas Constant Date: Thu, 7 Mar 2024 18:23:26 -0500 Subject: [PATCH] fix undefined image description, fix #632 --- .../attachement-image/attachement-image.component.html | 2 +- src/app/services/mastodon.service.ts | 10 +++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/app/components/stream/status/attachements/attachement-image/attachement-image.component.html b/src/app/components/stream/status/attachements/attachement-image/attachement-image.component.html index 72ccc2ac..08481752 100644 --- a/src/app/components/stream/status/attachements/attachement-image/attachement-image.component.html +++ b/src/app/components/stream/status/attachements/attachement-image/attachement-image.component.html @@ -1,5 +1,5 @@
-
ALT
+
ALT
diff --git a/src/app/services/mastodon.service.ts b/src/app/services/mastodon.service.ts index cc69ce0f..418a316d 100644 --- a/src/app/services/mastodon.service.ts +++ b/src/app/services/mastodon.service.ts @@ -398,11 +398,13 @@ export class MastodonService { uploadMediaAttachment(account: AccountInfo, file: File, description: string): Promise { let input = new FormData(); input.append('file', file); + if (description !== null && description !== undefined) { input.append('description', description); } else { input.append('description', ''); } + const route = `https://${account.instance}${this.apiRoutes.uploadMediaAttachment}`; const headers = new HttpHeaders({ 'Authorization': `Bearer ${account.token.access_token}` }); return this.httpClient.post(route, input, { headers: headers }).toPromise(); @@ -411,7 +413,13 @@ export class MastodonService { //TODO: add focus support updateMediaAttachment(account: AccountInfo, mediaId: string, description: string): Promise { let input = new FormData(); - input.append('description', description); + + if (description !== null && description !== undefined) { + input.append('description', description); + } else { + input.append('description', ''); + } + const route = `https://${account.instance}${this.apiRoutes.updateMediaAttachment.replace('{0}', mediaId)}`; const headers = new HttpHeaders({ 'Authorization': `Bearer ${account.token.access_token}` }); return this.httpClient.put(route, input, { headers: headers }).toPromise();