mirror of
https://github.com/NicolasConstant/sengi
synced 2024-12-22 13:54:10 +01:00
ensure all alt media are updated, fix #430
This commit is contained in:
parent
22cad9e22d
commit
eac8c6120a
@ -537,7 +537,7 @@ export class CreateStatusComponent implements OnInit, OnDestroy {
|
||||
return false;
|
||||
}
|
||||
|
||||
onSubmit(): boolean {
|
||||
async onSubmit(): Promise<boolean> {
|
||||
if (this.isSending || this.mentionTooFarAwayError) return false;
|
||||
|
||||
this.isSending = true;
|
||||
@ -558,9 +558,10 @@ export class CreateStatusComponent implements OnInit, OnDestroy {
|
||||
break;
|
||||
}
|
||||
|
||||
const mediaAttachments = this.mediaService.mediaSubject.value.map(x => x.attachment);
|
||||
|
||||
const acc = this.toolsService.getSelectedAccounts()[0];
|
||||
|
||||
const mediaAttachments = (await this.mediaService.retrieveUpToDateMedia(acc)).map(x => x.attachment);
|
||||
|
||||
let usableStatus: Promise<Status>;
|
||||
if (this.statusReplyingToWrapper) {
|
||||
usableStatus = this.toolsService.getStatusUsableByAccount(acc, this.statusReplyingToWrapper);
|
||||
|
@ -51,10 +51,10 @@ export class MediaService {
|
||||
});
|
||||
}
|
||||
|
||||
update(account: AccountInfo, media: MediaWrapper) {
|
||||
update(account: AccountInfo, media: MediaWrapper): Promise<void> {
|
||||
if (media.attachment.description === media.description) return;
|
||||
|
||||
this.mastodonService.updateMediaAttachment(account, media.attachment.id, media.description)
|
||||
return this.mastodonService.updateMediaAttachment(account, media.attachment.id, media.description)
|
||||
.then((att: Attachment) => {
|
||||
let medias = this.mediaSubject.value;
|
||||
let updatedMedia = medias.filter(x => x.id === media.id)[0];
|
||||
@ -66,6 +66,20 @@ export class MediaService {
|
||||
});
|
||||
}
|
||||
|
||||
async retrieveUpToDateMedia(account: AccountInfo): Promise<MediaWrapper[]> {
|
||||
const allMedia = this.mediaSubject.value;
|
||||
let allPromises: Promise<any>[] = [];
|
||||
|
||||
for (const m of allMedia) {
|
||||
let t = this.update(account, m);
|
||||
allPromises.push(t);
|
||||
}
|
||||
|
||||
await Promise.all(allPromises);
|
||||
|
||||
return allMedia;
|
||||
}
|
||||
|
||||
addExistingMedia(media: MediaWrapper){
|
||||
if(!this.fileCache[media.attachment.url]) return;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user