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