mirror of
https://github.com/oxen-io/session-desktop.git
synced 2023-12-14 02:12:57 +01:00
fix: replaced getMessageBySenderAndSentAt with getMessageBySenderAndTimestamp
which does the same thing but is more verbose
This commit is contained in:
parent
ad38b15809
commit
bd8ce826a8
4 changed files with 2 additions and 38 deletions
|
@ -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,
|
||||
|
|
|
@ -45,7 +45,6 @@ const channelsToMake = new Set([
|
|||
'getMessageCountByType',
|
||||
'removeAllMessagesInConversation',
|
||||
'getMessageCount',
|
||||
'getMessageBySenderAndSentAt',
|
||||
'filterAlreadyFetchedOpengroupMessage',
|
||||
'getMessageBySenderAndTimestamp',
|
||||
'getMessageIdsFromServerIds',
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue