fix undefined image description, fix #632

This commit is contained in:
Nicolas Constant 2024-03-07 18:23:26 -05:00
parent c4de387f86
commit d2221d539c
2 changed files with 10 additions and 2 deletions

View File

@ -1,5 +1,5 @@
<div class="image">
<div class="image__alt" *ngIf="displayAltLabel">ALT</div>
<div class="image__alt" *ngIf="displayAltLabel && attachment.description" title="{{ attachment.description }}">ALT</div>
<a *ngIf="status" href class="image__status" (click)="openStatus()" (auxclick)="openStatus()" title="open status">
<fa-icon class="image__status--icon" [icon]="faExternalLinkAlt"></fa-icon>
</a>

View File

@ -398,11 +398,13 @@ export class MastodonService {
uploadMediaAttachment(account: AccountInfo, file: File, description: string): Promise<Attachment> {
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<Attachment>(route, input, { headers: headers }).toPromise();
@ -411,7 +413,13 @@ export class MastodonService {
//TODO: add focus support
updateMediaAttachment(account: AccountInfo, mediaId: string, description: string): Promise<Attachment> {
let input = new FormData();
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<Attachment>(route, input, { headers: headers }).toPromise();