From f5312b9463e9d9397430d39263e65722f5a3b36d Mon Sep 17 00:00:00 2001 From: Fedor Indutny <79877362+indutny-signal@users.noreply.github.com> Date: Tue, 21 Dec 2021 21:01:09 +0100 Subject: [PATCH] Fix getUnreadReactionsAndMarkRead --- ts/sql/Server.ts | 2 +- ts/test-electron/sql/markRead_test.ts | 24 +++++++++++++++++++----- 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/ts/sql/Server.ts b/ts/sql/Server.ts index 5c69c1f967d0..b5f020c7d6ae 100644 --- a/ts/sql/Server.ts +++ b/ts/sql/Server.ts @@ -2152,7 +2152,7 @@ async function getUnreadReactionsAndMarkRead({ const unreadMessages: Array = db .prepare( ` - SELECT rowid, targetAuthorUuid, targetTimestamp, messageId + SELECT reactions.rowid, targetAuthorUuid, targetTimestamp, messageId FROM reactions JOIN messages on messages.id IS reactions.messageId WHERE diff --git a/ts/test-electron/sql/markRead_test.ts b/ts/test-electron/sql/markRead_test.ts index b50451f59333..691507fa5b37 100644 --- a/ts/test-electron/sql/markRead_test.ts +++ b/ts/test-electron/sql/markRead_test.ts @@ -417,6 +417,17 @@ describe('sql/markRead', () => { const storyId = getUuid(); const ourUuid = getUuid(); + const pad: Array = Array.from({ length: 4 }, _ => { + return { + id: getUuid(), + body: 'pad message', + type: 'incoming', + conversationId, + sent_at: start - 1, + received_at: start - 1, + timestamp: start - 1, + }; + }); const message1: MessageAttributesType = { id: getUuid(), body: 'message 1', @@ -464,11 +475,14 @@ describe('sql/markRead', () => { timestamp: start + 5, }; - await saveMessages([message1, message2, message3, message4, message5], { - forceSave: true, - ourUuid, - }); - assert.lengthOf(await _getAllMessages(), 5); + await saveMessages( + [...pad, message1, message2, message3, message4, message5], + { + forceSave: true, + ourUuid, + } + ); + assert.lengthOf(await _getAllMessages(), pad.length + 5); const reaction1: ReactionType = { conversationId,