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

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.

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.
gitea-actions bot added 1 commit 2026-10-17 13:00:05 +00:00
fix(chat): default the read cursor to 0 when counting unread
PR — Ouverture automatique / create-pr (push) Successful in 2s
9bfc356b9d
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.
Esiah approved these changes 2026-10-17 13:00:42 +00:00
Esiah left a comment
Owner

LGTM

LGTM
Esiah merged commit f9ff6ee02c into main 2026-10-17 13:00:48 +00:00
Esiah deleted branch fix/chat-unread-badge 2026-10-17 13:00:48 +00:00
Sign in to join this conversation.
No Reviewers
No labels
2 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Esiah/CoHaiSe-CLOUD#10