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