[mastodon-client] Also return edit history if post is unedited

This commit is contained in:
Laura Hausmann 2023-10-02 17:55:32 +02:00
parent 137ede02ce
commit 267624c7a3
No known key found for this signature in database
GPG Key ID: D044E84C5BE01605

View File

@ -154,13 +154,11 @@ export class NoteHelpers {
}
public static async getNoteEditHistory(note: Note): Promise<MastodonEntity.StatusEdit[]> {
if (!note.updatedAt) return [];
const cache = UserHelpers.getFreshAccountCache();
const account = Promise.resolve(note.user ?? await UserHelpers.getUserCached(note.userId, cache))
.then(p => UserConverter.encode(p, cache));
const edits = await NoteEdits.find({where: {noteId: note.id}, order: {id: "ASC"}});
const history: Promise<MastodonEntity.StatusEdit>[] = [];
if (edits.length < 1) return [];
const curr = {
id: note.id,
@ -169,7 +167,7 @@ export class NoteHelpers {
text: note.text,
cw: note.cw,
fileIds: note.fileIds,
updatedAt: note.updatedAt
updatedAt: note.updatedAt ?? note.createdAt
}
edits.push(curr);