Merge branch 'main' into starter-packs
This commit is contained in:
@@ -415,12 +415,14 @@ export const ComposePost = observer(function ComposePost({
|
||||
bottomBarAnimatedStyle,
|
||||
} = useAnimatedBorders()
|
||||
|
||||
const keyboardVerticalOffset = useKeyboardVerticalOffset()
|
||||
|
||||
return (
|
||||
<KeyboardAvoidingView
|
||||
testID="composePostView"
|
||||
behavior={isIOS ? 'padding' : 'height'}
|
||||
keyboardVerticalOffset={isIOS ? 70 : 0}
|
||||
style={[a.flex_1]}>
|
||||
keyboardVerticalOffset={keyboardVerticalOffset}
|
||||
style={a.flex_1}>
|
||||
<View style={[a.flex_1, viewStyles]} aria-modal accessibilityViewIsModal>
|
||||
<Animated.View style={topBarAnimatedStyle}>
|
||||
<View style={styles.topbarInner}>
|
||||
@@ -741,6 +743,19 @@ function useAnimatedBorders() {
|
||||
}
|
||||
}
|
||||
|
||||
function useKeyboardVerticalOffset() {
|
||||
const {top} = useSafeAreaInsets()
|
||||
|
||||
// Android etc
|
||||
if (!isIOS) return 0
|
||||
|
||||
// iPhone SE
|
||||
if (top === 20) return 40
|
||||
|
||||
// all other iPhones
|
||||
return top + 10
|
||||
}
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
topbarInner: {
|
||||
flexDirection: 'row',
|
||||
|
||||
@@ -150,16 +150,27 @@ export const TextInput = React.forwardRef(function TextInputImpl(
|
||||
attributes: {
|
||||
class: modeClass,
|
||||
},
|
||||
handlePaste: (_, event) => {
|
||||
const items = event.clipboardData?.items
|
||||
handlePaste: (view, event) => {
|
||||
const clipboardData = event.clipboardData
|
||||
|
||||
if (items === undefined) {
|
||||
return
|
||||
if (clipboardData) {
|
||||
if (clipboardData.types.includes('text/html')) {
|
||||
// Rich-text formatting is pasted, try retrieving plain text
|
||||
const text = clipboardData.getData('text/plain')
|
||||
|
||||
// `pasteText` will invoke this handler again, but `clipboardData` will be null.
|
||||
view.pasteText(text)
|
||||
|
||||
// Return `true` to prevent ProseMirror's default paste behavior.
|
||||
return true
|
||||
} else {
|
||||
// Otherwise, try retrieving images from the clipboard
|
||||
|
||||
getImageFromUri(clipboardData.items, (uri: string) => {
|
||||
textInputWebEmitter.emit('photo-pasted', uri)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
getImageFromUri(items, (uri: string) => {
|
||||
textInputWebEmitter.emit('photo-pasted', uri)
|
||||
})
|
||||
},
|
||||
handleKeyDown: (_, event) => {
|
||||
if ((event.metaKey || event.ctrlKey) && event.code === 'Enter') {
|
||||
|
||||
@@ -71,8 +71,11 @@ let ProfileMenu = ({
|
||||
const loggedOutWarningPromptControl = Prompt.usePromptControl()
|
||||
|
||||
const showLoggedOutWarning = React.useMemo(() => {
|
||||
return !!profile.labels?.find(label => label.val === '!no-unauthenticated')
|
||||
}, [profile.labels])
|
||||
return (
|
||||
profile.did !== currentAccount?.did &&
|
||||
!!profile.labels?.find(label => label.val === '!no-unauthenticated')
|
||||
)
|
||||
}, [currentAccount, profile])
|
||||
|
||||
const invalidateProfileQuery = React.useCallback(() => {
|
||||
queryClient.invalidateQueries({
|
||||
|
||||
@@ -11,6 +11,7 @@ import {sanitizeHandle} from 'lib/strings/handles'
|
||||
import {niceDate} from 'lib/strings/time'
|
||||
import {TypographyVariant} from 'lib/ThemeContext'
|
||||
import {isAndroid, isWeb} from 'platform/detection'
|
||||
import {atoms as a} from '#/alf'
|
||||
import {ProfileHoverCard} from '#/components/ProfileHoverCard'
|
||||
import {TextLinkOnWebOnly} from './Link'
|
||||
import {Text} from './text/Text'
|
||||
@@ -39,9 +40,13 @@ let PostMeta = (opts: PostMetaOpts): React.ReactNode => {
|
||||
const prefetchProfileQuery = usePrefetchProfileQuery()
|
||||
|
||||
const profileLink = makeProfileLink(opts.author)
|
||||
const onPointerEnter = isWeb
|
||||
? () => prefetchProfileQuery(opts.author.did)
|
||||
: undefined
|
||||
const prefetchedProfile = React.useRef(false)
|
||||
const onPointerMove = React.useCallback(() => {
|
||||
if (!prefetchedProfile.current) {
|
||||
prefetchedProfile.current = true
|
||||
prefetchProfileQuery(opts.author.did)
|
||||
}
|
||||
}, [opts.author.did, prefetchProfileQuery])
|
||||
|
||||
const queryClient = useQueryClient()
|
||||
const onOpenAuthor = opts.onOpenAuthor
|
||||
@@ -66,37 +71,39 @@ let PostMeta = (opts: PostMetaOpts): React.ReactNode => {
|
||||
</View>
|
||||
)}
|
||||
<ProfileHoverCard inline did={opts.author.did}>
|
||||
<Text
|
||||
numberOfLines={1}
|
||||
style={[styles.maxWidth, pal.textLight, opts.displayNameStyle]}>
|
||||
<TextLinkOnWebOnly
|
||||
type={opts.displayNameType || 'lg-bold'}
|
||||
style={[pal.text]}
|
||||
lineHeight={1.2}
|
||||
disableMismatchWarning
|
||||
text={
|
||||
<>
|
||||
{sanitizeDisplayName(
|
||||
displayName,
|
||||
opts.moderation?.ui('displayName'),
|
||||
)}
|
||||
</>
|
||||
}
|
||||
href={profileLink}
|
||||
onBeforePress={onBeforePressAuthor}
|
||||
onPointerEnter={onPointerEnter}
|
||||
/>
|
||||
<TextLinkOnWebOnly
|
||||
type="md"
|
||||
disableMismatchWarning
|
||||
style={[pal.textLight, {flexShrink: 4}]}
|
||||
text={'\xa0' + sanitizeHandle(handle, '@')}
|
||||
href={profileLink}
|
||||
onBeforePress={onBeforePressAuthor}
|
||||
onPointerEnter={onPointerEnter}
|
||||
anchorNoUnderline
|
||||
/>
|
||||
</Text>
|
||||
<View
|
||||
onPointerMove={isWeb ? onPointerMove : undefined}
|
||||
style={[a.flex_1]}>
|
||||
<Text
|
||||
numberOfLines={1}
|
||||
style={[styles.maxWidth, pal.textLight, opts.displayNameStyle]}>
|
||||
<TextLinkOnWebOnly
|
||||
type={opts.displayNameType || 'lg-bold'}
|
||||
style={[pal.text]}
|
||||
lineHeight={1.2}
|
||||
disableMismatchWarning
|
||||
text={
|
||||
<>
|
||||
{sanitizeDisplayName(
|
||||
displayName,
|
||||
opts.moderation?.ui('displayName'),
|
||||
)}
|
||||
</>
|
||||
}
|
||||
href={profileLink}
|
||||
onBeforePress={onBeforePressAuthor}
|
||||
/>
|
||||
<TextLinkOnWebOnly
|
||||
type="md"
|
||||
disableMismatchWarning
|
||||
style={[pal.textLight, {flexShrink: 4}]}
|
||||
text={'\xa0' + sanitizeHandle(handle, '@')}
|
||||
href={profileLink}
|
||||
onBeforePress={onBeforePressAuthor}
|
||||
anchorNoUnderline
|
||||
/>
|
||||
</Text>
|
||||
</View>
|
||||
</ProfileHoverCard>
|
||||
{!isAndroid && (
|
||||
<Text
|
||||
|
||||
@@ -196,6 +196,9 @@ let PostDropdownBtn = ({
|
||||
)
|
||||
}, [postAuthor])
|
||||
|
||||
const showLoggedOutWarning =
|
||||
postAuthor.did !== currentAccount?.did && hideInPWI
|
||||
|
||||
const onSharePost = React.useCallback(() => {
|
||||
const url = toShareUrl(href)
|
||||
shareUrl(url)
|
||||
@@ -296,7 +299,7 @@ let PostDropdownBtn = ({
|
||||
testID="postDropdownShareBtn"
|
||||
label={isWeb ? _(msg`Copy link to post`) : _(msg`Share`)}
|
||||
onPress={() => {
|
||||
if (hideInPWI) {
|
||||
if (showLoggedOutWarning) {
|
||||
loggedOutWarningPromptControl.open()
|
||||
} else {
|
||||
onSharePost()
|
||||
|
||||
@@ -27,7 +27,7 @@ import {
|
||||
usePostLikeMutationQueue,
|
||||
usePostRepostMutationQueue,
|
||||
} from '#/state/queries/post'
|
||||
import {useRequireAuth} from '#/state/session'
|
||||
import {useRequireAuth, useSession} from '#/state/session'
|
||||
import {useComposerControls} from '#/state/shell/composer'
|
||||
import {atoms as a, useTheme} from '#/alf'
|
||||
import {useDialogControl} from '#/components/Dialog'
|
||||
@@ -64,6 +64,7 @@ let PostCtrls = ({
|
||||
const t = useTheme()
|
||||
const {_} = useLingui()
|
||||
const {openComposer} = useComposerControls()
|
||||
const {currentAccount} = useSession()
|
||||
const [queueLike, queueUnlike] = usePostLikeMutationQueue(post, logContext)
|
||||
const [queueRepost, queueUnrepost] = usePostRepostMutationQueue(
|
||||
post,
|
||||
@@ -75,10 +76,11 @@ let PostCtrls = ({
|
||||
const playHaptic = useHaptics()
|
||||
|
||||
const shouldShowLoggedOutWarning = React.useMemo(() => {
|
||||
return !!post.author.labels?.find(
|
||||
label => label.val === '!no-unauthenticated',
|
||||
return (
|
||||
post.author.did !== currentAccount?.did &&
|
||||
!!post.author.labels?.find(label => label.val === '!no-unauthenticated')
|
||||
)
|
||||
}, [post])
|
||||
}, [currentAccount, post])
|
||||
|
||||
const defaultCtrlColor = React.useMemo(
|
||||
() => ({
|
||||
|
||||
Reference in New Issue
Block a user