Fix issue with stale unread message counts (#10953)

This commit is contained in:
DS Boyce
2026-06-24 13:51:06 -07:00
committed by GitHub
parent f64b1258b6
commit da1f637160
5 changed files with 132 additions and 3 deletions
@@ -23,6 +23,7 @@ import * as bsky from '#/types/bsky'
import {RQKEY as CONVO_KEY} from './conversation'
import {
RQKEY_PARTIAL as UNREAD_COUNTS_RQKEY_PARTIAL,
UNREAD_ACCEPTED_CAP,
useUnreadCountsQuery,
} from './get-unread-counts'
import {
@@ -858,7 +859,15 @@ export function useUnreadMessageCount(): {
const total = accepted + Math.min(request, 1)
return {
count: total,
numUnread: total > 10 ? '10+' : String(total),
// accepted is sentinel-capped at UNREAD_ACCEPTED_CAP (meaning "more than
// cap - 1"). show the "+" overflow label only when accepted is actually
// capped - the +1 request nudge must not trip it at exactly cap - 1
// accepted convos. otherwise clamp the number to cap - 1 so the nudge
// never surfaces the sentinel value (31) itself
numUnread:
accepted >= UNREAD_ACCEPTED_CAP
? `${UNREAD_ACCEPTED_CAP - 1}+`
: String(Math.min(total, UNREAD_ACCEPTED_CAP - 1)),
// only needed when numUnread is undefined
hasNew: false,
}