fix bugginess
This commit is contained in:
@@ -791,10 +791,16 @@ function ReplyQuote({
|
||||
const t = useTheme()
|
||||
const {t: l} = useLingui()
|
||||
|
||||
const senderProfile = relatedProfiles.get(replyTo.sender.did)
|
||||
const senderName = senderProfile
|
||||
? createSanitizedDisplayName(senderProfile)
|
||||
: null
|
||||
const senderProfile = useMaybeProfileShadow(
|
||||
relatedProfiles.get(replyTo.sender.did),
|
||||
)
|
||||
// Hide the quoted content if we block, or are blocked by, the original
|
||||
// sender - mirroring how the message bubble itself is hidden.
|
||||
const isBlocked = senderProfile ? isBlockedOrBlocking(senderProfile) : false
|
||||
const senderName =
|
||||
senderProfile && !isBlocked
|
||||
? createSanitizedDisplayName(senderProfile)
|
||||
: null
|
||||
|
||||
const tintColor = isFromSelf ? t.palette.white : t.atoms.text.color
|
||||
const subtleColor = isFromSelf
|
||||
@@ -806,7 +812,10 @@ function ReplyQuote({
|
||||
|
||||
let text: string
|
||||
let subtle = false
|
||||
if (ChatBskyConvoDefs.isMessageView(replyTo)) {
|
||||
if (isBlocked) {
|
||||
text = l`Message hidden`
|
||||
subtle = true
|
||||
} else if (ChatBskyConvoDefs.isMessageView(replyTo)) {
|
||||
text = replyTo.text
|
||||
if (!text.trim()) {
|
||||
subtle = true
|
||||
@@ -833,7 +842,7 @@ function ReplyQuote({
|
||||
onPress={onPress}
|
||||
style={[
|
||||
a.mb_xs,
|
||||
a.flex_1,
|
||||
|
||||
a.gap_2xs,
|
||||
a.rounded_md,
|
||||
a.px_sm,
|
||||
|
||||
@@ -13,6 +13,7 @@ import Animated, {
|
||||
import {useSafeAreaInsets} from 'react-native-safe-area-context'
|
||||
import {GlassContainer} from 'expo-glass-effect'
|
||||
import {LinearGradient} from 'expo-linear-gradient'
|
||||
import {type $Typed, type ChatBskyConvoDefs} from '@atproto/api'
|
||||
import {ScrollEdgeEffect} from '@bsky.app/expo-scroll-edge-effect'
|
||||
import {useLingui} from '@lingui/react/macro'
|
||||
import {countGraphemes} from 'unicode-segmenter/grapheme'
|
||||
@@ -28,6 +29,7 @@ import {
|
||||
} from '#/state/messages/message-drafts'
|
||||
import {atoms as a, native, platform, tokens, useTheme, utils} from '#/alf'
|
||||
import {Composer, useComposerInternalApiRef} from '#/components/Composer'
|
||||
import {useMessageDialogs} from '#/components/dms/MessageOverlays'
|
||||
import * as EmojiPicker from '#/components/EmojiPicker'
|
||||
import {GlassView} from '#/components/GlassView'
|
||||
import {EmojiArc_Stroke2_Corner0_Rounded as EmojiSmileIcon} from '#/components/icons/Emoji'
|
||||
@@ -47,7 +49,10 @@ export function MessageComposer({
|
||||
loading = false,
|
||||
}: {
|
||||
textInputId?: string
|
||||
onSendMessage: (message: string) => void
|
||||
onSendMessage: (
|
||||
message: string,
|
||||
replyTo?: $Typed<ChatBskyConvoDefs.MessageView>,
|
||||
) => void
|
||||
hasEmbed: boolean
|
||||
setEmbed: (embedUrl: string | undefined) => void
|
||||
children?: React.ReactNode
|
||||
@@ -60,6 +65,7 @@ export function MessageComposer({
|
||||
const editable = !needsEmailVerification && !loading
|
||||
const {getDraft, clearDraft} = useMessageDraft()
|
||||
const composerInternalApiRef = useComposerInternalApiRef()
|
||||
const {replyTo, clearReply} = useMessageDialogs()
|
||||
|
||||
const [text, setText] = useState(getDraft)
|
||||
useSaveMessageDraft(text)
|
||||
@@ -80,7 +86,10 @@ export function MessageComposer({
|
||||
|
||||
const submitDisabled = !editable || (!hasEmbed && text.trim().length === 0)
|
||||
|
||||
const onSubmit = (message: string) => {
|
||||
const onSubmit = (
|
||||
message: string,
|
||||
replyTo: ChatBskyConvoDefs.MessageView | null,
|
||||
) => {
|
||||
if (!editable) return
|
||||
if (!hasEmbed && message.trim() === '') return
|
||||
const graphemeCount = countGraphemes(message)
|
||||
@@ -95,6 +104,7 @@ export function MessageComposer({
|
||||
clearDraft()
|
||||
playHaptic()
|
||||
setEmbed(undefined)
|
||||
clearReply()
|
||||
composerInternalApiRef.current?.clear()
|
||||
|
||||
if (IS_WEB) {
|
||||
@@ -103,7 +113,15 @@ export function MessageComposer({
|
||||
|
||||
// defer send by a frame so that the textinput resizes before we send the message
|
||||
requestAnimationFrame(() => {
|
||||
onSendMessage(message)
|
||||
onSendMessage(
|
||||
message,
|
||||
replyTo
|
||||
? {
|
||||
...replyTo,
|
||||
$type: 'chat.bsky.convo.defs#messageView',
|
||||
}
|
||||
: undefined,
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
@@ -129,18 +147,18 @@ export function MessageComposer({
|
||||
setTimeout(() => {
|
||||
if (isFlushingAutocorrectSuggestion.current) {
|
||||
isFlushingAutocorrectSuggestion.current = false
|
||||
onSubmit(text)
|
||||
onSubmit(text, replyTo)
|
||||
}
|
||||
}, 20)
|
||||
} else {
|
||||
onSubmit(text)
|
||||
onSubmit(text, replyTo)
|
||||
}
|
||||
}
|
||||
|
||||
const handleChange = (nextText: string) => {
|
||||
if (IS_IOS && isFlushingAutocorrectSuggestion.current) {
|
||||
isFlushingAutocorrectSuggestion.current = false
|
||||
onSubmit(nextText)
|
||||
onSubmit(nextText, replyTo)
|
||||
} else {
|
||||
setText(nextText)
|
||||
}
|
||||
|
||||
@@ -62,10 +62,7 @@ import {MessageListError} from '#/screens/Messages/components/MessageListError'
|
||||
import {atoms as a, platform, tokens, useTheme, web} from '#/alf'
|
||||
import {DateDivider} from '#/components/dms/DateDivider'
|
||||
import {MessageItem} from '#/components/dms/MessageItem'
|
||||
import {
|
||||
MessageOverlays,
|
||||
useMessageDialogs,
|
||||
} from '#/components/dms/MessageOverlays'
|
||||
import {MessageOverlays} from '#/components/dms/MessageOverlays'
|
||||
import {NewMessagesPill} from '#/components/dms/NewMessagesPill'
|
||||
import {SystemMessageGroup} from '#/components/dms/SystemMessageGroup'
|
||||
import {SystemMessageItem} from '#/components/dms/SystemMessageItem'
|
||||
@@ -741,17 +738,11 @@ function Composer({
|
||||
loading?: boolean
|
||||
useNewComposer: boolean
|
||||
}) {
|
||||
const {replyTo, clearReply} = useMessageDialogs()
|
||||
|
||||
const handleSendMessage = useNonReactiveCallback((message: string) => {
|
||||
void onSendMessage(
|
||||
message,
|
||||
replyTo
|
||||
? {...replyTo, $type: 'chat.bsky.convo.defs#messageView'}
|
||||
: undefined,
|
||||
)
|
||||
clearReply()
|
||||
})
|
||||
const handleSendMessage = useNonReactiveCallback(
|
||||
(message: string, replyTo?: $Typed<ChatBskyConvoDefs.MessageView>) => {
|
||||
void onSendMessage(message, replyTo)
|
||||
},
|
||||
)
|
||||
|
||||
const previews = (
|
||||
<>
|
||||
|
||||
Reference in New Issue
Block a user