fix: replaced getMessageBySenderAndSentAt with getMessageBySenderAndTimestamp

which does the same thing but is more verbose
This commit is contained in:
William Grant 2023-05-01 13:41:54 +10:00
parent ad38b15809
commit bd8ce826a8
4 changed files with 2 additions and 38 deletions

View file

@ -142,7 +142,6 @@ export const Data = {
removeMessagesByIds,
getMessageIdsFromServerIds,
getMessageById,
getMessageBySenderAndSentAt,
getMessageByServerId,
filterAlreadyFetchedOpengroupMessage,
getMessageBySenderAndTimestamp,
@ -427,24 +426,6 @@ async function getMessageById(
return new MessageModel(message);
}
async function getMessageBySenderAndSentAt({
source,
sentAt,
}: {
source: string;
sentAt: number;
}): Promise<MessageModel | null> {
const messages = await channels.getMessageBySenderAndSentAt({
source,
sentAt,
});
if (!messages || !messages.length) {
return null;
}
return new MessageModel(messages[0]);
}
async function getMessageByServerId(
conversationId: string,
serverId: number,

View file

@ -45,7 +45,6 @@ const channelsToMake = new Set([
'getMessageCountByType',
'removeAllMessagesInConversation',
'getMessageCount',
'getMessageBySenderAndSentAt',
'filterAlreadyFetchedOpengroupMessage',
'getMessageBySenderAndTimestamp',
'getMessageIdsFromServerIds',

View file

@ -1025,21 +1025,6 @@ function getMessageById(id: string) {
return jsonToObject(row.json);
}
function getMessageBySenderAndSentAt({ source, sentAt }: { source: string; sentAt: number }) {
const rows = assertGlobalInstance()
.prepare(
`SELECT json FROM ${MESSAGES_TABLE} WHERE
source = $source AND
sent_at = $sent_at;`
)
.all({
source,
sent_at: sentAt,
});
return map(rows, row => jsonToObject(row.json));
}
// serverIds are not unique so we need the conversationId
function getMessageByServerId(conversationId: string, serverId: number) {
const row = assertGlobalInstance()
@ -2474,7 +2459,6 @@ export const sqlNode = {
getUnreadCountByConversation,
getMessageCountByType,
getMessageBySenderAndSentAt,
filterAlreadyFetchedOpengroupMessage,
getMessageBySenderAndTimestamp,
getMessageIdsFromServerIds,

View file

@ -258,9 +258,9 @@ export async function isSwarmMessageDuplicate({
sentAt: number;
}) {
try {
const result = await Data.getMessageBySenderAndSentAt({
const result = await Data.getMessageBySenderAndTimestamp({
source,
sentAt,
timestamp: sentAt,
});
return Boolean(result);