Hide last message in chat list if it's blocked (#10800)
This commit is contained in:
@@ -2,6 +2,7 @@ import {AppBskyEmbedRecord, ChatBskyConvoDefs} from '@atproto/api'
|
||||
import {type I18n} from '@lingui/core'
|
||||
import {msg} from '@lingui/core/macro'
|
||||
|
||||
import {isBlockedOrBlocking} from '#/lib/moderation/blocked-and-muted'
|
||||
import {createSanitizedDisplayName} from '#/lib/moderation/create-sanitized-display-name'
|
||||
import {
|
||||
postUriToRelativePath,
|
||||
@@ -13,6 +14,7 @@ export type UserMessageInfo = {
|
||||
message: string | null
|
||||
sentAt: string
|
||||
reportableMessage?: ChatBskyConvoDefs.MessageView
|
||||
isBlockedMessage: boolean
|
||||
}
|
||||
|
||||
export function getMessageInfo({
|
||||
@@ -36,6 +38,7 @@ export function getMessageInfo({
|
||||
const isGroup = ChatBskyConvoDefs.isGroupConvo(convo.kind)
|
||||
|
||||
const reportableMessage = isFromMe ? undefined : lastMessage
|
||||
const isBlockedMessage = sender ? isBlockedOrBlocking(sender) : false
|
||||
|
||||
const prefix = (message: string) => {
|
||||
if (isFromMe) {
|
||||
@@ -89,5 +92,6 @@ export function getMessageInfo({
|
||||
message,
|
||||
sentAt: lastMessage.sentAt,
|
||||
reportableMessage,
|
||||
isBlockedMessage,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import type * as bsky from '#/types/bsky'
|
||||
|
||||
export function isBlockedOrBlocking(profile: bsky.profile.AnyProfileView) {
|
||||
return profile.viewer?.blockedBy || profile.viewer?.blocking
|
||||
return Boolean(profile.viewer?.blockedBy || profile.viewer?.blocking)
|
||||
}
|
||||
|
||||
export function isMuted(profile: bsky.profile.AnyProfileView) {
|
||||
|
||||
@@ -331,7 +331,9 @@ function BaseChatItem({
|
||||
i18n,
|
||||
})
|
||||
if (info) {
|
||||
lastMessage = info.message ?? lastMessage
|
||||
lastMessage = info.isBlockedMessage
|
||||
? l`This message is hidden`
|
||||
: (info.message ?? lastMessage)
|
||||
lastMessageSentAt = info.sentAt
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user