Ensure that call history messages are marked read when they are seen

This commit is contained in:
trevor-signal 2024-10-21 17:01:39 -04:00 committed by GitHub
parent 2ec79f5712
commit b4b1a8a62b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -3708,6 +3708,7 @@ function getCallHistory(
return parseUnknown(callHistoryDetailsSchema, row as unknown); return parseUnknown(callHistoryDetailsSchema, row as unknown);
} }
const READ_STATUS_READ = sqlConstant(ReadStatus.Read);
const SEEN_STATUS_UNSEEN = sqlConstant(SeenStatus.Unseen); const SEEN_STATUS_UNSEEN = sqlConstant(SeenStatus.Unseen);
const SEEN_STATUS_SEEN = sqlConstant(SeenStatus.Seen); const SEEN_STATUS_SEEN = sqlConstant(SeenStatus.Seen);
const CALL_STATUS_MISSED = sqlConstant(CallStatusValue.Missed); const CALL_STATUS_MISSED = sqlConstant(CallStatusValue.Missed);
@ -3933,6 +3934,7 @@ export function markAllCallHistoryRead(
} }
const jsonPatch = JSON.stringify({ const jsonPatch = JSON.stringify({
readStatus: ReadStatus.Read,
seenStatus: SeenStatus.Seen, seenStatus: SeenStatus.Seen,
}); });
@ -3943,6 +3945,7 @@ export function markAllCallHistoryRead(
const [updateQuery, updateParams] = sql` const [updateQuery, updateParams] = sql`
UPDATE messages UPDATE messages
SET SET
readStatus = ${READ_STATUS_READ},
seenStatus = ${SEEN_STATUS_SEEN}, seenStatus = ${SEEN_STATUS_SEEN},
json = json_patch(json, ${jsonPatch}) json = json_patch(json, ${jsonPatch})
WHERE messages.type IS 'call-history' WHERE messages.type IS 'call-history'