Remove unread state from locked chats (#10552)
This commit is contained in:
@@ -36,7 +36,10 @@ export function RecentChats({
|
||||
const ax = useAnalytics()
|
||||
const control = useDialogContext()
|
||||
const {currentAccount} = useSession()
|
||||
const {data} = useListConvosQuery({status: 'accepted'})
|
||||
const {data} = useListConvosQuery({
|
||||
status: 'accepted',
|
||||
lockStatus: 'unlocked',
|
||||
})
|
||||
const convos = data?.pages[0]?.convos?.slice(0, 10)
|
||||
const moderationOpts = useModerationOpts()
|
||||
const navigation = useNavigation<NavigationProp>()
|
||||
|
||||
@@ -114,6 +114,7 @@ export function SearchablePeopleList({
|
||||
const {data: convos} = useListConvosQuery({
|
||||
enabled: showRecentConvos,
|
||||
status: 'accepted',
|
||||
lockStatus: 'unlocked',
|
||||
})
|
||||
|
||||
const items = useMemo(() => {
|
||||
|
||||
@@ -41,6 +41,7 @@ import {type ConvoWithDetails, parseConvoView} from '#/components/dms/util'
|
||||
import {Bell2Off_Filled_Corner0_Rounded as BellStroke} from '#/components/icons/Bell2'
|
||||
import {type Props as SVGIconProps} from '#/components/icons/common'
|
||||
import {Envelope_Open_Stroke2_Corner0_Rounded as EnvelopeOpen} from '#/components/icons/EnveopeOpen'
|
||||
import {Lock_Stroke2_Corner2_Rounded as LockIcon} from '#/components/icons/Lock'
|
||||
import {Trash_Stroke2_Corner0_Rounded} from '#/components/icons/Trash'
|
||||
import {Link} from '#/components/Link'
|
||||
import {useMenuControl} from '#/components/Menu'
|
||||
@@ -265,10 +266,7 @@ function BaseChatItem({
|
||||
const hasUnread =
|
||||
convo.view.unreadCount > 0 &&
|
||||
!isDeletedAccount &&
|
||||
!(
|
||||
convo.kind === 'group' &&
|
||||
convo.details.lockStatus === 'locked-permanently'
|
||||
)
|
||||
(convo.kind !== 'group' || convo.details.lockStatus === 'unlocked')
|
||||
|
||||
const blockInfo = useMemo(() => {
|
||||
if (!primaryProfileModeration) return {listBlocks: [], userBlock: undefined}
|
||||
@@ -355,6 +353,12 @@ function BaseChatItem({
|
||||
}
|
||||
}
|
||||
|
||||
// Chat locked - override message
|
||||
if (convo.kind === 'group' && convo.details.lockStatus !== 'unlocked') {
|
||||
lastMessage = l`This chat is locked`
|
||||
LastMessageIcon = LockIcon
|
||||
}
|
||||
|
||||
return {
|
||||
lastMessage,
|
||||
LastMessageIcon,
|
||||
|
||||
@@ -29,8 +29,13 @@ export const RQKEY = (
|
||||
status: 'accepted' | 'request' | 'all',
|
||||
readState: 'all' | 'unread' = 'all',
|
||||
kind: 'all' | 'group' | 'direct' = 'all',
|
||||
lockStatus:
|
||||
| 'unlocked'
|
||||
| 'locked'
|
||||
| 'locked-permanently'
|
||||
| undefined = undefined,
|
||||
limit?: number,
|
||||
) => [RQKEY_ROOT, status, readState, kind, limit]
|
||||
) => [RQKEY_ROOT, status, readState, kind, lockStatus, limit]
|
||||
type RQPageParam = string | undefined
|
||||
|
||||
export function useListConvosQuery({
|
||||
@@ -39,18 +44,20 @@ export function useListConvosQuery({
|
||||
readState = 'all',
|
||||
kind = 'all',
|
||||
limit = DEFAULT_LIMIT,
|
||||
lockStatus,
|
||||
}: {
|
||||
enabled?: boolean
|
||||
status?: 'request' | 'accepted'
|
||||
readState?: 'all' | 'unread'
|
||||
kind?: 'all' | 'group' | 'direct'
|
||||
limit?: number
|
||||
lockStatus?: 'unlocked' | 'locked' | 'locked-permanently'
|
||||
} = {}) {
|
||||
const agent = useAgent()
|
||||
|
||||
return useInfiniteQuery({
|
||||
enabled,
|
||||
queryKey: RQKEY(status ?? 'all', readState, kind, limit),
|
||||
queryKey: RQKEY(status ?? 'all', readState, kind, lockStatus, limit),
|
||||
queryFn: async ({pageParam}) => {
|
||||
const {data} = await agent.chat.bsky.convo.listConvos(
|
||||
{
|
||||
@@ -58,6 +65,7 @@ export function useListConvosQuery({
|
||||
cursor: pageParam,
|
||||
readState: readState === 'unread' ? 'unread' : undefined,
|
||||
kind: kind === 'all' ? undefined : kind,
|
||||
lockStatus,
|
||||
status,
|
||||
},
|
||||
{headers: DM_SERVICE_HEADERS},
|
||||
@@ -106,6 +114,7 @@ export function ListConvosProviderInner({
|
||||
const {refetch, data} = useListConvosQuery({
|
||||
readState: 'unread',
|
||||
limit: UNREAD_LIMIT,
|
||||
lockStatus: 'unlocked',
|
||||
})
|
||||
const messagesBus = useMessagesEventBus()
|
||||
const queryClient = useQueryClient()
|
||||
|
||||
Reference in New Issue
Block a user