fix(chat): default the read cursor to 0 when counting unread #10

Merged
Esiah merged 1 commits from fix/chat-unread-badge into main 2026-10-17 13:00:48 +00:00
1 Commits
Author SHA1 Message Date
Esiah 9bfc356b9d fix(chat): default the read cursor to 0 when counting unread
PR — Ouverture automatique / create-pr (push) Successful in 2s
The unread count compared message ids against COALESCE over a scalar
subquery with no fallback. When a user had never opened a discussion
there was no chat_reads row, so the subquery returned NULL and
`m.id > NULL` was never true: the folder never got a badge even though
messages from others were unread.

Give COALESCE an explicit 0 default so discussions that were never
opened count all of the others' messages as unread.
2026-10-17 14:59:09 +02:00