refactor: rename getMessageBySenderAndTimestamp to getMessageBySenderAndSentAt

its more clear what parameters are needed
This commit is contained in:
William Grant 2023-05-11 11:58:02 +10:00
parent d706ecdead
commit 1ff2969750
6 changed files with 9 additions and 15 deletions

View file

@ -144,7 +144,7 @@ export const Data = {
getMessageById,
getMessageByServerId,
filterAlreadyFetchedOpengroupMessage,
getMessageBySenderAndTimestamp,
getMessageBySenderAndSentAt,
getUnreadByConversation,
getUnreadCountByConversation,
markAllAsReadByConversationNoExpiration,
@ -454,14 +454,14 @@ async function filterAlreadyFetchedOpengroupMessage(
* @param source senders id
* @param timestamp the timestamp of the message - not to be confused with the serverTimestamp. This is equivalent to sent_at
*/
async function getMessageBySenderAndTimestamp({
async function getMessageBySenderAndSentAt({
source,
timestamp,
}: {
source: string;
timestamp: number;
}): Promise<MessageModel | null> {
const messages = await channels.getMessageBySenderAndTimestamp({
const messages = await channels.getMessageBySenderAndSentAt({
source,
timestamp,
});

View file

@ -46,7 +46,7 @@ const channelsToMake = new Set([
'removeAllMessagesInConversation',
'getMessageCount',
'filterAlreadyFetchedOpengroupMessage',
'getMessageBySenderAndTimestamp',
'getMessageBySenderAndSentAt',
'getMessageIdsFromServerIds',
'getMessageById',
'getMessagesBySentAt',

View file

@ -1062,13 +1062,7 @@ function getMessagesCountBySender({ source }: { source: string }) {
return count['count(*)'] || 0;
}
function getMessageBySenderAndTimestamp({
source,
timestamp,
}: {
source: string;
timestamp: number;
}) {
function getMessageBySenderAndSentAt({ source, timestamp }: { source: string; timestamp: number }) {
const rows = assertGlobalInstance()
.prepare(
`SELECT json FROM ${MESSAGES_TABLE} WHERE
@ -2460,7 +2454,7 @@ export const sqlNode = {
getMessageCountByType,
filterAlreadyFetchedOpengroupMessage,
getMessageBySenderAndTimestamp,
getMessageBySenderAndSentAt,
getMessageIdsFromServerIds,
getMessageById,
getMessagesBySentAt,

View file

@ -565,7 +565,7 @@ async function handleUnsendMessage(envelope: EnvelopePlus, unsendMessage: Signal
return;
}
const messageToDelete = await Data.getMessageBySenderAndTimestamp({
const messageToDelete = await Data.getMessageBySenderAndSentAt({
source: messageAuthor,
timestamp: toNumber(timestamp),
});

View file

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

View file

@ -394,7 +394,7 @@ async function getMessages({
if (!results.length) {
const dbResult = (
await Data.getMessageBySenderAndTimestamp({ source: sender, timestamp })
await Data.getMessageBySenderAndSentAt({ source: sender, timestamp })
)?.getMessageModelProps();
if (dbResult) {
results = [dbResult];