factor out latest_note logic into LatestNoteService

This commit is contained in:
Hazelnoot 2024-10-13 18:11:16 -04:00
parent c55af9c3b3
commit 93cf2f9045
5 changed files with 167 additions and 115 deletions

View file

@ -82,4 +82,16 @@ export class SkLatestNote {
isQuote: isRenote(note) && isQuote(note),
};
}
/**
* Checks if two notes would produce equivalent compound keys.
*/
static areEquivalent(first: MiNote, second: MiNote): boolean {
return (
first.userId === second.userId &&
first.visibility === second.visibility &&
(first.replyId != null) === (second.replyId != null) &&
(isRenote(first) && isQuote(first)) === (isRenote(second) && isQuote(second))
);
}
}