Handle new sync message MarkedAsRead for Calls Tab

This commit is contained in:
ayumi-signal 2024-03-11 11:18:55 -07:00 committed by GitHub
parent b410d14753
commit c332bd240f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 72 additions and 16 deletions

View file

@ -649,7 +649,9 @@ export type DataInterface = {
cleanupCallHistoryMessages: () => Promise<void>;
getCallHistoryUnreadCount(): Promise<number>;
markCallHistoryRead(callId: string): Promise<void>;
markAllCallHistoryRead(): Promise<ReadonlyArray<string>>;
markAllCallHistoryRead(
beforeTimestamp: number
): Promise<ReadonlyArray<string>>;
getCallHistoryMessageByCallId(options: {
conversationId: string;
callId: string;

View file

@ -3487,13 +3487,16 @@ async function markCallHistoryRead(callId: string): Promise<void> {
db.prepare(query).run(params);
}
async function markAllCallHistoryRead(): Promise<ReadonlyArray<string>> {
async function markAllCallHistoryRead(
beforeTimestamp: number
): Promise<ReadonlyArray<string>> {
const db = await getWritableInstance();
return db.transaction(() => {
const where = sqlFragment`
WHERE messages.type IS 'call-history'
AND messages.seenStatus IS ${SEEN_STATUS_UNSEEN}
AND messages.sent_at <= ${beforeTimestamp};
`;
const [selectQuery, selectParams] = sql`