mirror of
https://github.com/tooot-app/app
synced 2025-01-27 08:51:26 +01:00
Fixed #158
This commit is contained in:
parent
23bc9aa5f3
commit
0991d50240
@ -14,17 +14,17 @@ import { useQueryClient } from 'react-query'
|
||||
import { useSelector } from 'react-redux'
|
||||
|
||||
export interface Props {
|
||||
menuItems: ContextMenuAction[]
|
||||
status: Mastodon.Status
|
||||
queryKey: QueryKeyTimeline
|
||||
actions: ContextMenuAction[]
|
||||
queryKey?: QueryKeyTimeline
|
||||
rootQueryKey?: QueryKeyTimeline
|
||||
id: Mastodon.Account['id']
|
||||
}
|
||||
|
||||
const contextMenuAccount = ({
|
||||
menuItems,
|
||||
status,
|
||||
actions,
|
||||
queryKey,
|
||||
rootQueryKey
|
||||
rootQueryKey,
|
||||
id: accountId
|
||||
}: Props) => {
|
||||
const { theme } = useTheme()
|
||||
const { t } = useTranslation('componentContextMenu')
|
||||
@ -68,12 +68,12 @@ const contextMenuAccount = ({
|
||||
getInstanceAccount,
|
||||
(prev, next) => prev.id === next.id
|
||||
)
|
||||
const ownAccount = instanceAccount?.id === status.account.id
|
||||
const ownAccount = instanceAccount?.id === accountId
|
||||
|
||||
if (!ownAccount) {
|
||||
switch (Platform.OS) {
|
||||
case 'ios':
|
||||
menuItems.push({
|
||||
actions.push({
|
||||
id: 'account',
|
||||
title: t('account.title'),
|
||||
inlineChildren: true,
|
||||
@ -99,7 +99,7 @@ const contextMenuAccount = ({
|
||||
})
|
||||
break
|
||||
default:
|
||||
menuItems.push(
|
||||
actions.push(
|
||||
{
|
||||
id: 'account-mute',
|
||||
title: t('account.mute.action'),
|
||||
@ -123,7 +123,6 @@ const contextMenuAccount = ({
|
||||
}
|
||||
|
||||
return (id: string) => {
|
||||
const url = status.url || status.uri
|
||||
switch (id) {
|
||||
case 'account-mute':
|
||||
analytics('timeline_shared_headeractions_account_mute_press', {
|
||||
@ -132,7 +131,7 @@ const contextMenuAccount = ({
|
||||
mutateion.mutate({
|
||||
type: 'updateAccountProperty',
|
||||
queryKey,
|
||||
id: status.account.id,
|
||||
id: accountId,
|
||||
payload: { property: 'mute' }
|
||||
})
|
||||
break
|
||||
@ -143,7 +142,7 @@ const contextMenuAccount = ({
|
||||
mutateion.mutate({
|
||||
type: 'updateAccountProperty',
|
||||
queryKey,
|
||||
id: status.account.id,
|
||||
id: accountId,
|
||||
payload: { property: 'block' }
|
||||
})
|
||||
break
|
||||
@ -154,7 +153,7 @@ const contextMenuAccount = ({
|
||||
mutateion.mutate({
|
||||
type: 'updateAccountProperty',
|
||||
queryKey,
|
||||
id: status.account.id,
|
||||
id: accountId,
|
||||
payload: { property: 'reports' }
|
||||
})
|
||||
break
|
@ -13,14 +13,14 @@ import { useQueryClient } from 'react-query'
|
||||
import { useSelector } from 'react-redux'
|
||||
|
||||
export interface Props {
|
||||
menuItems: ContextMenuAction[]
|
||||
actions: ContextMenuAction[]
|
||||
status: Mastodon.Status
|
||||
queryKey: QueryKeyTimeline
|
||||
rootQueryKey?: QueryKeyTimeline
|
||||
}
|
||||
|
||||
const contextMenuInstance = ({
|
||||
menuItems,
|
||||
actions,
|
||||
status,
|
||||
queryKey,
|
||||
rootQueryKey
|
||||
@ -49,7 +49,7 @@ const contextMenuInstance = ({
|
||||
if (currentInstance !== instance && instance) {
|
||||
switch (Platform.OS) {
|
||||
case 'ios':
|
||||
menuItems.push({
|
||||
actions.push({
|
||||
id: 'instance',
|
||||
title: t('instance.title'),
|
||||
actions: [
|
||||
@ -62,7 +62,7 @@ const contextMenuInstance = ({
|
||||
})
|
||||
break
|
||||
default:
|
||||
menuItems.push({
|
||||
actions.push({
|
||||
id: 'instance-block',
|
||||
title: t('instance.block.action', { instance }),
|
||||
destructive: true
|
@ -4,23 +4,21 @@ import { Platform, Share } from 'react-native'
|
||||
import { ContextMenuAction } from 'react-native-context-menu-view'
|
||||
|
||||
export interface Props {
|
||||
menuItems: ContextMenuAction[]
|
||||
status: Mastodon.Status
|
||||
actions: ContextMenuAction[]
|
||||
type: 'status' | 'account'
|
||||
url: string
|
||||
}
|
||||
|
||||
const contextMenuShare = ({ menuItems, status }: Props) => {
|
||||
const contextMenuShare = ({ actions, type, url }: Props) => {
|
||||
const { t } = useTranslation('componentContextMenu')
|
||||
|
||||
if (status.visibility !== 'direct') {
|
||||
menuItems.push({
|
||||
id: 'share',
|
||||
title: t(`share.status.action`),
|
||||
systemIcon: 'square.and.arrow.up'
|
||||
})
|
||||
}
|
||||
actions.push({
|
||||
id: 'share',
|
||||
title: t(`share.${type}.action`),
|
||||
systemIcon: 'square.and.arrow.up'
|
||||
})
|
||||
|
||||
return (id: string) => {
|
||||
const url = status.url || status.uri
|
||||
switch (id) {
|
||||
case 'share':
|
||||
analytics('timeline_shared_headeractions_share_press')
|
@ -21,14 +21,14 @@ import { useQueryClient } from 'react-query'
|
||||
import { useSelector } from 'react-redux'
|
||||
|
||||
export interface Props {
|
||||
menuItems: ContextMenuAction[]
|
||||
actions: ContextMenuAction[]
|
||||
status: Mastodon.Status
|
||||
queryKey: QueryKeyTimeline
|
||||
rootQueryKey?: QueryKeyTimeline
|
||||
}
|
||||
|
||||
const contextMenuStatus = ({
|
||||
menuItems,
|
||||
actions,
|
||||
status,
|
||||
queryKey,
|
||||
rootQueryKey
|
||||
@ -116,7 +116,7 @@ const contextMenuStatus = ({
|
||||
|
||||
switch (Platform.OS) {
|
||||
case 'ios':
|
||||
menuItems.push({
|
||||
actions.push({
|
||||
id: 'status',
|
||||
title: t('status.title'),
|
||||
inlineChildren: true,
|
||||
@ -124,7 +124,7 @@ const contextMenuStatus = ({
|
||||
})
|
||||
break
|
||||
default:
|
||||
menuItems.push(...accountMenuItems)
|
||||
actions.push(...accountMenuItems)
|
||||
break
|
||||
}
|
||||
}
|
@ -18,6 +18,7 @@ import { isEqual, uniqBy } from 'lodash'
|
||||
import React, { useCallback } from 'react'
|
||||
import { Pressable, View } from 'react-native'
|
||||
import { useSelector } from 'react-redux'
|
||||
import TimelineContextMenu from './Shared/ContextMenu'
|
||||
import TimelineFiltered, { shouldFilter } from './Shared/Filtered'
|
||||
import TimelineFullConversation from './Shared/FullConversation'
|
||||
|
||||
@ -58,103 +59,105 @@ const TimelineNotifications = React.memo(
|
||||
}, [])
|
||||
|
||||
return (
|
||||
<Pressable
|
||||
style={{
|
||||
padding: StyleConstants.Spacing.Global.PagePadding,
|
||||
backgroundColor: colors.backgroundDefault,
|
||||
paddingBottom: notification.status
|
||||
? 0
|
||||
: StyleConstants.Spacing.Global.PagePadding
|
||||
}}
|
||||
onPress={onPress}
|
||||
>
|
||||
{notification.type !== 'mention' ? (
|
||||
<TimelineActioned
|
||||
action={notification.type}
|
||||
account={notification.account}
|
||||
notification
|
||||
/>
|
||||
) : null}
|
||||
|
||||
<View
|
||||
<TimelineContextMenu status={notification.status} queryKey={queryKey}>
|
||||
<Pressable
|
||||
style={{
|
||||
opacity:
|
||||
notification.type === 'follow' ||
|
||||
notification.type === 'follow_request' ||
|
||||
notification.type === 'mention' ||
|
||||
notification.type === 'status'
|
||||
? 1
|
||||
: 0.5
|
||||
padding: StyleConstants.Spacing.Global.PagePadding,
|
||||
backgroundColor: colors.backgroundDefault,
|
||||
paddingBottom: notification.status
|
||||
? 0
|
||||
: StyleConstants.Spacing.Global.PagePadding
|
||||
}}
|
||||
onPress={onPress}
|
||||
onLongPress={() => {}}
|
||||
>
|
||||
<View style={{ flex: 1, width: '100%', flexDirection: 'row' }}>
|
||||
<TimelineAvatar
|
||||
queryKey={queryKey}
|
||||
account={actualAccount}
|
||||
highlighted={highlighted}
|
||||
/>
|
||||
<TimelineHeaderNotification
|
||||
queryKey={queryKey}
|
||||
notification={notification}
|
||||
{notification.type !== 'mention' ? (
|
||||
<TimelineActioned
|
||||
action={notification.type}
|
||||
account={notification.account}
|
||||
notification
|
||||
/>
|
||||
) : null}
|
||||
|
||||
<View
|
||||
style={{
|
||||
opacity:
|
||||
notification.type === 'follow' ||
|
||||
notification.type === 'follow_request' ||
|
||||
notification.type === 'mention' ||
|
||||
notification.type === 'status'
|
||||
? 1
|
||||
: 0.5
|
||||
}}
|
||||
>
|
||||
<View style={{ flex: 1, width: '100%', flexDirection: 'row' }}>
|
||||
<TimelineAvatar
|
||||
queryKey={queryKey}
|
||||
account={actualAccount}
|
||||
highlighted={highlighted}
|
||||
/>
|
||||
<TimelineHeaderNotification notification={notification} />
|
||||
</View>
|
||||
|
||||
{notification.status ? (
|
||||
<View
|
||||
style={{
|
||||
paddingTop: highlighted ? StyleConstants.Spacing.S : 0,
|
||||
paddingLeft: highlighted
|
||||
? 0
|
||||
: StyleConstants.Avatar.M + StyleConstants.Spacing.S
|
||||
}}
|
||||
>
|
||||
{notification.status.content.length > 0 ? (
|
||||
<TimelineContent
|
||||
status={notification.status}
|
||||
highlighted={highlighted}
|
||||
/>
|
||||
) : null}
|
||||
{notification.status.poll ? (
|
||||
<TimelinePoll
|
||||
queryKey={queryKey}
|
||||
statusId={notification.status.id}
|
||||
poll={notification.status.poll}
|
||||
reblog={false}
|
||||
sameAccount={
|
||||
notification.account.id === instanceAccount?.id
|
||||
}
|
||||
/>
|
||||
) : null}
|
||||
{notification.status.media_attachments.length > 0 ? (
|
||||
<TimelineAttachment status={notification.status} />
|
||||
) : null}
|
||||
{notification.status.card ? (
|
||||
<TimelineCard card={notification.status.card} />
|
||||
) : null}
|
||||
<TimelineFullConversation
|
||||
queryKey={queryKey}
|
||||
status={notification.status}
|
||||
/>
|
||||
</View>
|
||||
) : null}
|
||||
</View>
|
||||
|
||||
{notification.status ? (
|
||||
<View
|
||||
style={{
|
||||
paddingTop: highlighted ? StyleConstants.Spacing.S : 0,
|
||||
paddingLeft: highlighted
|
||||
? 0
|
||||
: StyleConstants.Avatar.M + StyleConstants.Spacing.S
|
||||
}}
|
||||
>
|
||||
{notification.status.content.length > 0 ? (
|
||||
<TimelineContent
|
||||
status={notification.status}
|
||||
highlighted={highlighted}
|
||||
/>
|
||||
) : null}
|
||||
{notification.status.poll ? (
|
||||
<TimelinePoll
|
||||
queryKey={queryKey}
|
||||
statusId={notification.status.id}
|
||||
poll={notification.status.poll}
|
||||
reblog={false}
|
||||
sameAccount={notification.account.id === instanceAccount?.id}
|
||||
/>
|
||||
) : null}
|
||||
{notification.status.media_attachments.length > 0 ? (
|
||||
<TimelineAttachment status={notification.status} />
|
||||
) : null}
|
||||
{notification.status.card ? (
|
||||
<TimelineCard card={notification.status.card} />
|
||||
) : null}
|
||||
<TimelineFullConversation
|
||||
queryKey={queryKey}
|
||||
status={notification.status}
|
||||
/>
|
||||
</View>
|
||||
<TimelineActions
|
||||
queryKey={queryKey}
|
||||
status={notification.status}
|
||||
highlighted={highlighted}
|
||||
accts={uniqBy(
|
||||
(
|
||||
[notification.status.account] as Mastodon.Account[] &
|
||||
Mastodon.Mention[]
|
||||
)
|
||||
.concat(notification.status.mentions)
|
||||
.filter(d => d?.id !== instanceAccount?.id),
|
||||
d => d?.id
|
||||
).map(d => d?.acct)}
|
||||
reblog={false}
|
||||
/>
|
||||
) : null}
|
||||
</View>
|
||||
|
||||
{notification.status ? (
|
||||
<TimelineActions
|
||||
queryKey={queryKey}
|
||||
status={notification.status}
|
||||
highlighted={highlighted}
|
||||
accts={uniqBy(
|
||||
(
|
||||
[notification.status.account] as Mastodon.Account[] &
|
||||
Mastodon.Mention[]
|
||||
)
|
||||
.concat(notification.status.mentions)
|
||||
.filter(d => d?.id !== instanceAccount?.id),
|
||||
d => d?.id
|
||||
).map(d => d?.acct)}
|
||||
reblog={false}
|
||||
/>
|
||||
) : null}
|
||||
</Pressable>
|
||||
</Pressable>
|
||||
</TimelineContextMenu>
|
||||
)
|
||||
},
|
||||
(prev, next) => isEqual(prev.notification, next.notification)
|
||||
|
@ -1,62 +1,79 @@
|
||||
import contextMenuAccount from '@components/ContextMenu/account'
|
||||
import contextMenuInstance from '@components/ContextMenu/instance'
|
||||
import contextMenuShare from '@components/ContextMenu/share'
|
||||
import contextMenuStatus from '@components/ContextMenu/status'
|
||||
import { QueryKeyTimeline } from '@utils/queryHooks/timeline'
|
||||
import React from 'react'
|
||||
import { createContext } from 'react'
|
||||
import ContextMenu, { ContextMenuAction } from 'react-native-context-menu-view'
|
||||
import contextMenuAccount from './ContextMenu/account'
|
||||
import contextMenuInstance from './ContextMenu/instance'
|
||||
import contextMenuShare from './ContextMenu/share'
|
||||
import contextMenuStatus from './ContextMenu/status'
|
||||
import ContextMenu, {
|
||||
ContextMenuAction,
|
||||
ContextMenuProps
|
||||
} from 'react-native-context-menu-view'
|
||||
|
||||
export interface Props {
|
||||
status: Mastodon.Status
|
||||
status?: Mastodon.Status
|
||||
queryKey?: QueryKeyTimeline
|
||||
rootQueryKey?: QueryKeyTimeline
|
||||
}
|
||||
|
||||
export const ContextMenuContext = createContext<ContextMenuAction[]>([])
|
||||
|
||||
const TimelineContextMenu: React.FC<Props> = ({
|
||||
const TimelineContextMenu: React.FC<Props & ContextMenuProps> = ({
|
||||
children,
|
||||
status,
|
||||
queryKey,
|
||||
rootQueryKey
|
||||
rootQueryKey,
|
||||
...props
|
||||
}) => {
|
||||
if (!queryKey) {
|
||||
if (!status || !queryKey) {
|
||||
return <>{children}</>
|
||||
}
|
||||
|
||||
const menuItems: ContextMenuAction[] = []
|
||||
const actions: ContextMenuAction[] = []
|
||||
|
||||
const shareOnPress = contextMenuShare({ menuItems, status })
|
||||
const shareOnPress =
|
||||
status.visibility !== 'direct'
|
||||
? contextMenuShare({
|
||||
actions,
|
||||
type: 'status',
|
||||
url: status.url || status.uri
|
||||
})
|
||||
: null
|
||||
const statusOnPress = contextMenuStatus({
|
||||
menuItems,
|
||||
actions,
|
||||
status,
|
||||
queryKey,
|
||||
rootQueryKey
|
||||
})
|
||||
const accountOnPress = contextMenuAccount({
|
||||
menuItems,
|
||||
status,
|
||||
actions,
|
||||
queryKey,
|
||||
rootQueryKey
|
||||
rootQueryKey,
|
||||
id: status.account.id
|
||||
})
|
||||
const instanceOnPress = contextMenuInstance({
|
||||
menuItems,
|
||||
actions,
|
||||
status,
|
||||
queryKey,
|
||||
rootQueryKey
|
||||
})
|
||||
|
||||
return (
|
||||
<ContextMenuContext.Provider value={menuItems}>
|
||||
<ContextMenuContext.Provider value={actions}>
|
||||
<ContextMenu
|
||||
actions={menuItems}
|
||||
actions={actions}
|
||||
onPress={({ nativeEvent: { id } }) => {
|
||||
shareOnPress(id)
|
||||
statusOnPress(id)
|
||||
accountOnPress(id)
|
||||
instanceOnPress(id)
|
||||
for (const on of [
|
||||
shareOnPress,
|
||||
statusOnPress,
|
||||
accountOnPress,
|
||||
instanceOnPress
|
||||
]) {
|
||||
on && on(id)
|
||||
}
|
||||
}}
|
||||
children={children}
|
||||
{...props}
|
||||
/>
|
||||
</ContextMenuContext.Provider>
|
||||
)
|
||||
|
@ -2,11 +2,10 @@ import Icon from '@components/Icon'
|
||||
import { QueryKeyTimeline } from '@utils/queryHooks/timeline'
|
||||
import { StyleConstants } from '@utils/styles/constants'
|
||||
import { useTheme } from '@utils/styles/ThemeManager'
|
||||
import React, { useContext, useRef } from 'react'
|
||||
import React, { useContext } from 'react'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import { Pressable, View } from 'react-native'
|
||||
import ContextMenu from 'react-native-context-menu-view'
|
||||
import { TouchableWithoutFeedback } from 'react-native-gesture-handler'
|
||||
import { ContextMenuContext } from './ContextMenu'
|
||||
import HeaderSharedAccount from './HeaderShared/Account'
|
||||
import HeaderSharedApplication from './HeaderShared/Application'
|
||||
@ -24,7 +23,7 @@ const TimelineHeaderDefault = ({ queryKey, status, highlighted }: Props) => {
|
||||
const { t } = useTranslation('componentContextMenu')
|
||||
const { colors } = useTheme()
|
||||
|
||||
const contextMenuItems = useContext(ContextMenuContext)
|
||||
const contextMenuContext = useContext(ContextMenuContext)
|
||||
|
||||
return (
|
||||
<View style={{ flex: 1, flexDirection: 'row' }}>
|
||||
@ -60,16 +59,9 @@ const TimelineHeaderDefault = ({ queryKey, status, highlighted }: Props) => {
|
||||
}}
|
||||
>
|
||||
<ContextMenu
|
||||
dropdownMenuMode={true}
|
||||
actions={contextMenuItems}
|
||||
// onPress={({ nativeEvent: { index, name } }) => {
|
||||
// console.log('index', index)
|
||||
// console.log('name', name)
|
||||
// // shareOnPress(name)
|
||||
// // statusOnPress(name)
|
||||
// accountOnPress(name)
|
||||
// // instanceOnPress(name)
|
||||
// }}
|
||||
dropdownMenuMode
|
||||
actions={contextMenuContext}
|
||||
onPress={() => {}}
|
||||
children={
|
||||
<Icon
|
||||
name='MoreHorizontal'
|
||||
|
@ -3,14 +3,12 @@ import {
|
||||
RelationshipIncoming,
|
||||
RelationshipOutgoing
|
||||
} from '@components/Relationship'
|
||||
import { useNavigation } from '@react-navigation/native'
|
||||
import { StackNavigationProp } from '@react-navigation/stack'
|
||||
import { RootStackParamList } from '@utils/navigation/navigators'
|
||||
import { QueryKeyTimeline } from '@utils/queryHooks/timeline'
|
||||
import { StyleConstants } from '@utils/styles/constants'
|
||||
import { useTheme } from '@utils/styles/ThemeManager'
|
||||
import React, { useMemo } from 'react'
|
||||
import React, { useContext, useMemo } from 'react'
|
||||
import { Pressable, View } from 'react-native'
|
||||
import ContextMenu from 'react-native-context-menu-view'
|
||||
import { ContextMenuContext } from './ContextMenu'
|
||||
import HeaderSharedAccount from './HeaderShared/Account'
|
||||
import HeaderSharedApplication from './HeaderShared/Application'
|
||||
import HeaderSharedCreated from './HeaderShared/Created'
|
||||
@ -18,14 +16,14 @@ import HeaderSharedMuted from './HeaderShared/Muted'
|
||||
import HeaderSharedVisibility from './HeaderShared/Visibility'
|
||||
|
||||
export interface Props {
|
||||
queryKey: QueryKeyTimeline
|
||||
notification: Mastodon.Notification
|
||||
}
|
||||
|
||||
const TimelineHeaderNotification = ({ queryKey, notification }: Props) => {
|
||||
const navigation = useNavigation<StackNavigationProp<RootStackParamList>>()
|
||||
const TimelineHeaderNotification = ({ notification }: Props) => {
|
||||
const { colors } = useTheme()
|
||||
|
||||
const contextMenuContext = useContext(ContextMenuContext)
|
||||
|
||||
const actions = useMemo(() => {
|
||||
switch (notification.type) {
|
||||
case 'follow':
|
||||
@ -42,18 +40,18 @@ const TimelineHeaderNotification = ({ queryKey, notification }: Props) => {
|
||||
justifyContent: 'center',
|
||||
paddingBottom: StyleConstants.Spacing.S
|
||||
}}
|
||||
onPress={() =>
|
||||
navigation.navigate('Screen-Actions', {
|
||||
queryKey,
|
||||
status: notification.status!,
|
||||
type: 'status'
|
||||
})
|
||||
}
|
||||
children={
|
||||
<Icon
|
||||
name='MoreHorizontal'
|
||||
color={colors.secondary}
|
||||
size={StyleConstants.Font.Size.L}
|
||||
<ContextMenu
|
||||
dropdownMenuMode
|
||||
actions={contextMenuContext}
|
||||
onPress={() => {}}
|
||||
children={
|
||||
<Icon
|
||||
name='MoreHorizontal'
|
||||
color={colors.secondary}
|
||||
size={StyleConstants.Font.Size.L}
|
||||
/>
|
||||
}
|
||||
/>
|
||||
}
|
||||
/>
|
||||
|
@ -1,14 +1,7 @@
|
||||
import analytics from '@components/analytics'
|
||||
import Button from '@components/Button'
|
||||
import { RootStackScreenProps } from '@utils/navigation/navigators'
|
||||
import {
|
||||
getInstanceAccount,
|
||||
getInstanceUrl
|
||||
} from '@utils/slices/instancesSlice'
|
||||
import { StyleConstants } from '@utils/styles/constants'
|
||||
import { useTheme } from '@utils/styles/ThemeManager'
|
||||
import React, { useCallback, useEffect } from 'react'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import { Dimensions, StyleSheet, View } from 'react-native'
|
||||
import {
|
||||
PanGestureHandler,
|
||||
@ -28,46 +21,13 @@ import {
|
||||
SafeAreaProvider,
|
||||
useSafeAreaInsets
|
||||
} from 'react-native-safe-area-context'
|
||||
import { useSelector } from 'react-redux'
|
||||
import ActionsAccount from './Actions/Account'
|
||||
import ActionsAltText from './Actions/AltText'
|
||||
import ActionsDomain from './Actions/Domain'
|
||||
import ActionsNotificationsFilter from './Actions/NotificationsFilter'
|
||||
import ActionsShare from './Actions/Share'
|
||||
import ActionsStatus from './Actions/Status'
|
||||
|
||||
const ScreenActions = ({
|
||||
route: { params },
|
||||
navigation
|
||||
}: RootStackScreenProps<'Screen-Actions'>) => {
|
||||
const { t } = useTranslation()
|
||||
|
||||
const instanceAccount = useSelector(
|
||||
getInstanceAccount,
|
||||
(prev, next) => prev?.id === next?.id
|
||||
)
|
||||
let sameAccount = false
|
||||
switch (params.type) {
|
||||
case 'status':
|
||||
sameAccount = instanceAccount?.id === params.status.account.id
|
||||
break
|
||||
case 'account':
|
||||
sameAccount = instanceAccount?.id === params.account.id
|
||||
break
|
||||
}
|
||||
|
||||
const instanceDomain = useSelector(getInstanceUrl)
|
||||
let sameDomain = true
|
||||
let statusDomain: string
|
||||
switch (params.type) {
|
||||
case 'status':
|
||||
statusDomain = params.status.uri
|
||||
? params.status.uri.split(new RegExp(/\/\/(.*?)\//))[1]
|
||||
: ''
|
||||
sameDomain = instanceDomain === statusDomain
|
||||
break
|
||||
}
|
||||
|
||||
const { colors } = useTheme()
|
||||
const insets = useSafeAreaInsets()
|
||||
|
||||
@ -105,40 +65,6 @@ const ScreenActions = ({
|
||||
|
||||
const actions = () => {
|
||||
switch (params.type) {
|
||||
case 'status':
|
||||
return (
|
||||
<>
|
||||
{!sameAccount ? (
|
||||
<ActionsAccount
|
||||
queryKey={params.queryKey}
|
||||
rootQueryKey={params.rootQueryKey}
|
||||
account={params.status.account}
|
||||
dismiss={dismiss}
|
||||
/>
|
||||
) : null}
|
||||
</>
|
||||
)
|
||||
case 'account':
|
||||
return (
|
||||
<>
|
||||
{!sameAccount ? (
|
||||
<ActionsAccount account={params.account} dismiss={dismiss} />
|
||||
) : null}
|
||||
<ActionsShare
|
||||
url={params.account.url}
|
||||
type={params.type}
|
||||
dismiss={dismiss}
|
||||
/>
|
||||
<Button
|
||||
type='text'
|
||||
content={t('common:buttons.cancel')}
|
||||
onPress={() => {
|
||||
analytics('bottomsheet_acknowledge')
|
||||
}}
|
||||
style={styles.button}
|
||||
/>
|
||||
</>
|
||||
)
|
||||
case 'notifications_filter':
|
||||
return <ActionsNotificationsFilter />
|
||||
case 'alt_text':
|
||||
|
@ -128,7 +128,9 @@ const ComposeEditAttachmentImage: React.FC<Props> = ({ index }) => {
|
||||
height: imageDimensionis.height
|
||||
}}
|
||||
source={{
|
||||
uri: theAttachmentLocal?.uri || theAttachmentRemote?.preview_url
|
||||
uri: theAttachmentLocal?.path
|
||||
? `file://${theAttachmentLocal?.path}`
|
||||
: theAttachmentRemote?.preview_url
|
||||
}}
|
||||
/>
|
||||
<PanGestureHandler onGestureEvent={onGestureEvent}>
|
||||
|
@ -34,7 +34,7 @@ const ComposeEditAttachmentRoot: React.FC<Props> = ({ index }) => {
|
||||
video={
|
||||
video.local
|
||||
? ({
|
||||
url: video.local.uri,
|
||||
url: `file://${video.local.path}`,
|
||||
preview_url: video.local.local_thumbnail,
|
||||
blurhash: video.remote?.blurhash
|
||||
} as Mastodon.AttachmentVideo)
|
||||
|
@ -58,7 +58,7 @@ const composeReducer = (
|
||||
attachments: {
|
||||
...state.attachments,
|
||||
uploads: state.attachments.uploads.map(upload =>
|
||||
upload.local?.uri === action.payload.local?.uri
|
||||
upload.local?.path === action.payload.local?.path
|
||||
? { ...upload, remote: action.payload.remote, uploading: false }
|
||||
: upload
|
||||
)
|
||||
|
7
src/screens/Compose/utils/types.d.ts
vendored
7
src/screens/Compose/utils/types.d.ts
vendored
@ -2,7 +2,7 @@ import { ImageOrVideo } from 'react-native-image-crop-picker'
|
||||
|
||||
export type ExtendedAttachment = {
|
||||
remote?: Mastodon.Attachment
|
||||
local?: Pick<ImageOrVideo, 'path' | 'width' | 'height'> & {
|
||||
local?: Pick<ImageOrVideo, 'path' | 'width' | 'height' | 'mime'> & {
|
||||
type: 'image' | 'video' | 'unknown'
|
||||
local_thumbnail?: string
|
||||
hash?: string
|
||||
@ -121,7 +121,10 @@ export type ComposeAction =
|
||||
}
|
||||
| {
|
||||
type: 'attachment/upload/end'
|
||||
payload: { remote: Mastodon.Attachment; local: ImageInfo }
|
||||
payload: {
|
||||
remote: Mastodon.Attachment
|
||||
local: Pick<ImageOrVideo, 'path' | 'width' | 'height' | 'mime'>
|
||||
}
|
||||
}
|
||||
| {
|
||||
type: 'attachment/upload/fail'
|
||||
|
@ -1,5 +1,3 @@
|
||||
import analytics from '@components/analytics'
|
||||
import { HeaderRight } from '@components/Header'
|
||||
import Timeline from '@components/Timeline'
|
||||
import TimelineDefault from '@components/Timeline/Default'
|
||||
import SegmentedControl from '@react-native-community/segmented-control'
|
||||
@ -23,8 +21,7 @@ const TabSharedAccount: React.FC<
|
||||
> = ({
|
||||
route: {
|
||||
params: { account }
|
||||
},
|
||||
navigation
|
||||
}
|
||||
}) => {
|
||||
const { t, i18n } = useTranslation('screenTabs')
|
||||
const { colors, mode } = useTheme()
|
||||
@ -33,33 +30,6 @@ const TabSharedAccount: React.FC<
|
||||
|
||||
const scrollY = useSharedValue(0)
|
||||
|
||||
useEffect(() => {
|
||||
const updateHeaderRight = () =>
|
||||
navigation.setOptions({
|
||||
headerRight: () => (
|
||||
<HeaderRight
|
||||
accessibilityLabel={t('shared.account.actions.accessibilityLabel', {
|
||||
user: data?.acct
|
||||
})}
|
||||
accessibilityHint={t('shared.account.actions.accessibilityHint')}
|
||||
content='MoreHorizontal'
|
||||
onPress={() => {
|
||||
analytics('bottomsheet_open_press', {
|
||||
page: 'account'
|
||||
})
|
||||
// @ts-ignore
|
||||
navigation.navigate('Screen-Actions', {
|
||||
type: 'account',
|
||||
account
|
||||
})
|
||||
}}
|
||||
background
|
||||
/>
|
||||
)
|
||||
})
|
||||
return updateHeaderRight()
|
||||
}, [i18n.language])
|
||||
|
||||
const onScroll = useCallback(({ nativeEvent }) => {
|
||||
scrollY.value = nativeEvent.contentOffset.y
|
||||
}, [])
|
||||
|
@ -1,4 +1,6 @@
|
||||
import { HeaderCenter, HeaderLeft } from '@components/Header'
|
||||
import contextMenuAccount from '@components/ContextMenu/account'
|
||||
import contextMenuShare from '@components/ContextMenu/share'
|
||||
import { HeaderCenter, HeaderLeft, HeaderRight } from '@components/Header'
|
||||
import { ParseEmojis } from '@components/Parse'
|
||||
import CustomText from '@components/Text'
|
||||
import { createNativeStackNavigator } from '@react-navigation/native-stack'
|
||||
@ -16,6 +18,7 @@ import { debounce } from 'lodash'
|
||||
import React from 'react'
|
||||
import { Trans, useTranslation } from 'react-i18next'
|
||||
import { Platform, TextInput, View } from 'react-native'
|
||||
import ContextMenu, { ContextMenuAction } from 'react-native-context-menu-view'
|
||||
|
||||
const TabSharedRoot = ({
|
||||
Stack
|
||||
@ -36,7 +39,10 @@ const TabSharedRoot = ({
|
||||
name='Tab-Shared-Account'
|
||||
component={TabSharedAccount}
|
||||
options={({
|
||||
navigation
|
||||
navigation,
|
||||
route: {
|
||||
params: { account }
|
||||
}
|
||||
}: TabSharedStackScreenProps<'Tab-Shared-Account'>) => {
|
||||
return {
|
||||
headerTransparent: true,
|
||||
@ -46,7 +52,44 @@ const TabSharedRoot = ({
|
||||
title: '',
|
||||
headerLeft: () => (
|
||||
<HeaderLeft onPress={() => navigation.goBack()} background />
|
||||
)
|
||||
),
|
||||
headerRight: () => {
|
||||
const actions: ContextMenuAction[] = []
|
||||
|
||||
const shareOnPress = contextMenuShare({
|
||||
actions,
|
||||
type: 'account',
|
||||
url: account.url
|
||||
})
|
||||
const accountOnPress = contextMenuAccount({
|
||||
actions,
|
||||
id: account.id
|
||||
})
|
||||
|
||||
return (
|
||||
<ContextMenu
|
||||
actions={actions}
|
||||
onPress={({ nativeEvent: { id } }) => {
|
||||
shareOnPress(id)
|
||||
accountOnPress(id)
|
||||
}}
|
||||
dropdownMenuMode
|
||||
>
|
||||
<HeaderRight
|
||||
accessibilityLabel={t(
|
||||
'shared.account.actions.accessibilityLabel',
|
||||
{ user: account.acct }
|
||||
)}
|
||||
accessibilityHint={t(
|
||||
'shared.account.actions.accessibilityHint'
|
||||
)}
|
||||
content='MoreHorizontal'
|
||||
onPress={() => {}}
|
||||
background
|
||||
/>
|
||||
</ContextMenu>
|
||||
)
|
||||
}
|
||||
}
|
||||
}}
|
||||
/>
|
||||
|
@ -7,16 +7,6 @@ import { QueryKeyTimeline } from '@utils/queryHooks/timeline'
|
||||
export type RootStackParamList = {
|
||||
'Screen-Tabs': NavigatorScreenParams<ScreenTabsStackParamList>
|
||||
'Screen-Actions':
|
||||
| {
|
||||
type: 'status'
|
||||
queryKey: QueryKeyTimeline
|
||||
rootQueryKey?: QueryKeyTimeline
|
||||
status: Mastodon.Status
|
||||
}
|
||||
| {
|
||||
type: 'account'
|
||||
account: Mastodon.Account
|
||||
}
|
||||
| {
|
||||
type: 'notifications_filter'
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user