[Chat] Fix footer logic (#10785)
This commit is contained in:
@@ -709,7 +709,13 @@ function getFooterState(
|
|||||||
convoState: ActiveConvoStates,
|
convoState: ActiveConvoStates,
|
||||||
hasAcceptOverride?: boolean,
|
hasAcceptOverride?: boolean,
|
||||||
): FooterState {
|
): FooterState {
|
||||||
if (convoState.convo.view.status === 'request' && !hasAcceptOverride) {
|
const isRequest =
|
||||||
|
convoState.convo.view.status === 'request' && !hasAcceptOverride
|
||||||
|
|
||||||
|
// For group chats, the request footer is driven purely off status: the owner
|
||||||
|
// is always 'accepted' so never sees it, while members the owner added are
|
||||||
|
// 'request' until they accept. This holds even before any messages load.
|
||||||
|
if (convoState.convo.kind === 'group' && isRequest) {
|
||||||
return 'request'
|
return 'request'
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -721,6 +727,15 @@ function getFooterState(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// For direct chats, only show the request footer once there's a message. The
|
||||||
|
// viewer's status stays 'request' until they send their first message, so an
|
||||||
|
// empty direct request is one the viewer started themselves (show the
|
||||||
|
// composer), whereas any message present must be an incoming one from the
|
||||||
|
// other user (show the accept/reject footer).
|
||||||
|
if (isRequest) {
|
||||||
|
return 'request'
|
||||||
|
}
|
||||||
|
|
||||||
return 'standard'
|
return 'standard'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -738,7 +738,16 @@ function calculateCount(
|
|||||||
moderateProfile(convo.primaryMember, moderationOpts).blocked ||
|
moderateProfile(convo.primaryMember, moderationOpts).blocked ||
|
||||||
convo.primaryMember.handle === 'missing.invalid' ||
|
convo.primaryMember.handle === 'missing.invalid' ||
|
||||||
(convo.kind === 'group' && convo.details.lockStatus !== 'unlocked')
|
(convo.kind === 'group' && convo.details.lockStatus !== 'unlocked')
|
||||||
const unreadCount = !shouldIgnore && convo.view.unreadCount > 0 ? 1 : 0
|
const unreadJoinRequestCount =
|
||||||
|
convo.kind === 'group'
|
||||||
|
? (convo.details.unreadJoinRequestCount ?? 0)
|
||||||
|
: 0
|
||||||
|
|
||||||
|
const unreadCount =
|
||||||
|
!shouldIgnore &&
|
||||||
|
(convo.view.unreadCount > 0 || unreadJoinRequestCount > 0)
|
||||||
|
? 1
|
||||||
|
: 0
|
||||||
|
|
||||||
return acc + unreadCount
|
return acc + unreadCount
|
||||||
}, 0) ?? 0
|
}, 0) ?? 0
|
||||||
|
|||||||
Reference in New Issue
Block a user