Increase unread cap to 99+ (#10985)
This commit is contained in:
@@ -10,13 +10,12 @@ export const RQKEY = (includeGroupChats: boolean) =>
|
||||
[RQKEY_ROOT, includeGroupChats] as const
|
||||
export const RQKEY_PARTIAL = [RQKEY_ROOT] as const
|
||||
|
||||
// the server sentinel-caps the badge counts: unreadAcceptedConvos maxes at 31
|
||||
// (meaning "more than 30") and unreadRequestConvos at 11 (meaning "more than
|
||||
// 10"). at the cap the value is no longer an exact count, so consumers must not
|
||||
// treat it as one - both the optimistic decrement and the badge display ceiling
|
||||
// key off these.
|
||||
export const UNREAD_ACCEPTED_CAP = 31
|
||||
export const UNREAD_REQUEST_CAP = 11
|
||||
// the server sentinel-caps the badge counts: unreadAcceptedConvos and
|
||||
// unreadRequestConvos max out at 100 (meaning "more than 99"). at the cap the
|
||||
// value is no longer an exact count, so consumers must not treat it as one -
|
||||
// both the optimistic decrement and the badge display ceiling key off these.
|
||||
export const UNREAD_ACCEPTED_CAP = 100
|
||||
export const UNREAD_REQUEST_CAP = 100
|
||||
|
||||
export function useUnreadCountsQuery() {
|
||||
const agent = useAgent()
|
||||
|
||||
@@ -856,18 +856,16 @@ export function useUnreadMessageCount(): {
|
||||
const request = data?.unreadRequestConvos ?? 0
|
||||
|
||||
if (accepted > 0) {
|
||||
const total = accepted + Math.min(request, 1)
|
||||
return {
|
||||
count: total,
|
||||
count: accepted,
|
||||
// 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
|
||||
// capped, otherwise clamp the number to cap - 1 so we never surface the
|
||||
// sentinel value (100) itself
|
||||
numUnread:
|
||||
accepted >= UNREAD_ACCEPTED_CAP
|
||||
? `${UNREAD_ACCEPTED_CAP - 1}+`
|
||||
: String(Math.min(total, UNREAD_ACCEPTED_CAP - 1)),
|
||||
: String(Math.min(accepted, UNREAD_ACCEPTED_CAP - 1)),
|
||||
// only needed when numUnread is undefined
|
||||
hasNew: false,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user