Add migration for unread call history messages and fix json.seenStatus

This commit is contained in:
ayumi-signal 2024-03-05 11:54:01 -08:00 committed by GitHub
parent 407b6b0f97
commit 6fd117bde7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 268 additions and 4 deletions

View file

@ -3471,9 +3471,16 @@ async function getCallHistoryUnreadCount(): Promise<number> {
async function markCallHistoryRead(callId: string): Promise<void> {
const db = await getWritableInstance();
const jsonPatch = JSON.stringify({
seenStatus: SeenStatus.Seen,
});
const [query, params] = sql`
UPDATE messages
SET seenStatus = ${SEEN_STATUS_UNSEEN}
SET
seenStatus = ${SEEN_STATUS_UNSEEN}
json = json_patch(json, ${jsonPatch})
WHERE type IS 'call-history'
AND callId IS ${callId}
`;
@ -3497,9 +3504,15 @@ async function markAllCallHistoryRead(): Promise<ReadonlyArray<string>> {
const conversationIds = db.prepare(selectQuery).pluck().all(selectParams);
const jsonPatch = JSON.stringify({
seenStatus: SeenStatus.Seen,
});
const [updateQuery, updateParams] = sql`
UPDATE messages
SET seenStatus = ${SEEN_STATUS_SEEN}
SET
seenStatus = ${SEEN_STATUS_SEEN},
json = json_patch(json, ${jsonPatch})
${where};
`;