From e19193c9d0dbb624d6e11ee2f97f1986f526b5e7 Mon Sep 17 00:00:00 2001 From: Hazelnoot Date: Mon, 14 Oct 2024 11:35:16 -0400 Subject: [PATCH] unify logic of `SkLatestNote.areEquivalent` and `SkLatestNote.keyFor` --- packages/backend/src/models/LatestNote.ts | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/packages/backend/src/models/LatestNote.ts b/packages/backend/src/models/LatestNote.ts index ff8815bd42..064fcccc0a 100644 --- a/packages/backend/src/models/LatestNote.ts +++ b/packages/backend/src/models/LatestNote.ts @@ -87,11 +87,14 @@ export class SkLatestNote { * Checks if two notes would produce equivalent compound keys. */ static areEquivalent(first: MiNote, second: MiNote): boolean { + const firstKey = SkLatestNote.keyFor(first); + const secondKey = SkLatestNote.keyFor(second); + return ( - first.userId === second.userId && - first.visibility === second.visibility && - (first.replyId != null) === (second.replyId != null) && - (isRenote(first) && isQuote(first)) === (isRenote(second) && isQuote(second)) + firstKey.userId === secondKey.userId && + firstKey.isPublic === secondKey.isPublic && + firstKey.isReply === secondKey.isReply && + firstKey.isQuote === secondKey.isQuote ); } }