Fix issue with stale unread message counts (#10953)
This commit is contained in:
@@ -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,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user