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