From 73cceab31f5c365b8bd176e518ccd2ba1b30dfd2 Mon Sep 17 00:00:00 2001 From: William Grant Date: Thu, 12 Oct 2023 15:36:48 +1100 Subject: [PATCH] refactor: getDisappearingUnreadByConversation to getUnreadDisappearingByConversation since reading causes disappearing --- ts/data/data.ts | 6 +++--- ts/data/dataInit.ts | 2 +- ts/node/sql.ts | 6 +++--- ts/receiver/configMessage.ts | 6 +++--- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/ts/data/data.ts b/ts/data/data.ts index e425f4202..3488f7993 100644 --- a/ts/data/data.ts +++ b/ts/data/data.ts @@ -345,11 +345,11 @@ async function getUnreadByConversation( return new MessageCollection(messages); } -async function getDisappearingUnreadByConversation( +async function getUnreadDisappearingByConversation( conversationId: string, sentBeforeTimestamp: number ): Promise { - const messages = await channels.getDisappearingUnreadByConversation( + const messages = await channels.getUnreadDisappearingByConversation( conversationId, sentBeforeTimestamp ); @@ -806,7 +806,7 @@ export const Data = { getMessageByServerId, filterAlreadyFetchedOpengroupMessage, getUnreadByConversation, - getDisappearingUnreadByConversation, + getUnreadDisappearingByConversation, getUnreadCountByConversation, markAllAsReadByConversationNoExpiration, getMessageCountByType, diff --git a/ts/data/dataInit.ts b/ts/data/dataInit.ts index 9dd65c9a4..7846a6508 100644 --- a/ts/data/dataInit.ts +++ b/ts/data/dataInit.ts @@ -42,7 +42,7 @@ const channelsToMake = new Set([ 'removeMessage', 'removeMessagesByIds', 'getUnreadByConversation', - 'getDisappearingUnreadByConversation', + 'getUnreadDisappearingByConversation', 'markAllAsReadByConversationNoExpiration', 'getUnreadCountByConversation', 'getMessageCountByType', diff --git a/ts/node/sql.ts b/ts/node/sql.ts index 3bdb127ce..0f7f05c62 100644 --- a/ts/node/sql.ts +++ b/ts/node/sql.ts @@ -1,7 +1,7 @@ +import * as BetterSqlite3 from '@signalapp/better-sqlite3'; import { app, clipboard, dialog, Notification } from 'electron'; import fs from 'fs'; import path from 'path'; -import * as BetterSqlite3 from '@signalapp/better-sqlite3'; import rimraf from 'rimraf'; import { base64_variants, from_base64, to_hex } from 'libsodium-wrappers-sumo'; @@ -1161,7 +1161,7 @@ function getUnreadByConversation(conversationId: string, sentBeforeTimestamp: nu return map(rows, row => jsonToObject(row.json)); } -function getDisappearingUnreadByConversation(conversationId: string, sentBeforeTimestamp: number) { +function getUnreadDisappearingByConversation(conversationId: string, sentBeforeTimestamp: number) { const rows = assertGlobalInstance() .prepare( `SELECT * FROM ${MESSAGES_TABLE} WHERE @@ -2419,7 +2419,7 @@ export const sqlNode = { removeMessagesByIds, removeAllMessagesInConversation, getUnreadByConversation, - getDisappearingUnreadByConversation, + getUnreadDisappearingByConversation, markAllAsReadByConversationNoExpiration, getUnreadCountByConversation, getMessageCountByType, diff --git a/ts/receiver/configMessage.ts b/ts/receiver/configMessage.ts index c075912df..c54a4af2c 100644 --- a/ts/receiver/configMessage.ts +++ b/ts/receiver/configMessage.ts @@ -5,6 +5,7 @@ import { ConfigDumpData } from '../data/configDump/configDump'; import { Data } from '../data/data'; import { SettingsKey } from '../data/settings-key'; import { ConversationInteraction } from '../interactions'; +import { deleteAllMessagesByConvoIdNoConfirmation } from '../interactions/conversationInteractions'; import { CONVERSATION_PRIORITIES, ConversationTypeEnum } from '../models/conversationAttributes'; import { SignalService } from '../protobuf'; import { ClosedGroup } from '../session'; @@ -16,6 +17,7 @@ import { getOpenGroupManager } from '../session/apis/open_group_api/opengroupV2/ import { OpenGroupUtils } from '../session/apis/open_group_api/utils'; import { getOpenGroupV2ConversationId } from '../session/apis/open_group_api/utils/OpenGroupUtils'; import { getSwarmPollingInstance } from '../session/apis/snode_api'; +import { getExpiriesFromSnode } from '../session/apis/snode_api/getExpiriesRequest'; import { getConversationController } from '../session/conversations'; import { IncomingMessage } from '../session/messages/incoming/IncomingMessage'; import { Profile, ProfileManager } from '../session/profile_manager/ProfileManager'; @@ -39,7 +41,6 @@ import { isSignInByLinking, setLastProfileUpdateTimestamp, } from '../util/storage'; -import { deleteAllMessagesByConvoIdNoConfirmation } from '../interactions/conversationInteractions'; // eslint-disable-next-line import/no-unresolved, import/extensions import { ConfigWrapperObjectTypes } from '../webworker/workers/browser/libsession_worker_functions'; import { @@ -54,7 +55,6 @@ import { addKeyPairToCacheAndDBIfNeeded, handleNewClosedGroup } from './closedGr import { HexKeyPair } from './keypairs'; import { queueAllCachedFromSource } from './receiver'; import { EnvelopePlus } from './types'; -import { getExpiriesFromSnode } from '../session/apis/snode_api/getExpiriesRequest'; function groupByVariant( incomingConfigs: Array> @@ -735,7 +735,7 @@ async function applyConvoVolatileUpdateFromWrapper( foundConvo.getExpirationMode() === 'legacy') && foundConvo.getExpireTimer() > 0 ) { - const messages2Expire = await Data.getDisappearingUnreadByConversation( + const messages2Expire = await Data.getUnreadDisappearingByConversation( convoId, lastReadMessageTimestamp );