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