mirror of https://github.com/tooot-app/app
Try fix #451
Android does not support true context menu anyway, thus removing per toot component.
This commit is contained in:
parent
bf8826fec4
commit
fbfae52627
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "tooot",
|
"name": "tooot",
|
||||||
"version": "4.6.1",
|
"version": "4.6.2",
|
||||||
"description": "tooot for Mastodon",
|
"description": "tooot for Mastodon",
|
||||||
"author": "xmflsct <me@xmflsct.com>",
|
"author": "xmflsct <me@xmflsct.com>",
|
||||||
"license": "GPL-3.0-or-later",
|
"license": "GPL-3.0-or-later",
|
||||||
|
|
|
@ -17,7 +17,7 @@ import { StyleConstants } from '@utils/styles/constants'
|
||||||
import { useTheme } from '@utils/styles/ThemeManager'
|
import { useTheme } from '@utils/styles/ThemeManager'
|
||||||
import { uniqBy } from 'lodash'
|
import { uniqBy } from 'lodash'
|
||||||
import React, { useRef } from 'react'
|
import React, { useRef } from 'react'
|
||||||
import { Pressable, StyleProp, View, ViewStyle } from 'react-native'
|
import { Platform, Pressable, StyleProp, View, ViewStyle } from 'react-native'
|
||||||
import { useSelector } from 'react-redux'
|
import { useSelector } from 'react-redux'
|
||||||
import TimelineContextMenu from './Shared/ContextMenu'
|
import TimelineContextMenu from './Shared/ContextMenu'
|
||||||
import TimelineFeedback from './Shared/Feedback'
|
import TimelineFeedback from './Shared/Feedback'
|
||||||
|
@ -156,6 +156,15 @@ const TimelineDefault: React.FC<Props> = ({
|
||||||
|
|
||||||
return disableOnPress ? (
|
return disableOnPress ? (
|
||||||
<View style={mainStyle}>{main()}</View>
|
<View style={mainStyle}>{main()}</View>
|
||||||
|
) : Platform.OS === 'android' ? (
|
||||||
|
<Pressable
|
||||||
|
accessible={highlighted ? false : true}
|
||||||
|
style={mainStyle}
|
||||||
|
onPress={onPress}
|
||||||
|
onLongPress={() => {}}
|
||||||
|
>
|
||||||
|
{main()}
|
||||||
|
</Pressable>
|
||||||
) : (
|
) : (
|
||||||
<TimelineContextMenu
|
<TimelineContextMenu
|
||||||
copiableContent={copiableContent}
|
copiableContent={copiableContent}
|
||||||
|
|
|
@ -17,7 +17,7 @@ import { StyleConstants } from '@utils/styles/constants'
|
||||||
import { useTheme } from '@utils/styles/ThemeManager'
|
import { useTheme } from '@utils/styles/ThemeManager'
|
||||||
import { isEqual, uniqBy } from 'lodash'
|
import { isEqual, uniqBy } from 'lodash'
|
||||||
import React, { useCallback, useRef } from 'react'
|
import React, { useCallback, useRef } from 'react'
|
||||||
import { Pressable, View } from 'react-native'
|
import { Platform, Pressable, View } from 'react-native'
|
||||||
import { useSelector } from 'react-redux'
|
import { useSelector } from 'react-redux'
|
||||||
import TimelineContextMenu from './Shared/ContextMenu'
|
import TimelineContextMenu from './Shared/ContextMenu'
|
||||||
import TimelineFiltered, { shouldFilter } from './Shared/Filtered'
|
import TimelineFiltered, { shouldFilter } from './Shared/Filtered'
|
||||||
|
@ -29,129 +29,146 @@ export interface Props {
|
||||||
highlighted?: boolean
|
highlighted?: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
const TimelineNotifications = React.memo(
|
const TimelineNotifications: React.FC<Props> = ({
|
||||||
({ notification, queryKey, highlighted = false }: Props) => {
|
notification,
|
||||||
const copiableContent = useRef<{ content: string; complete: boolean }>({
|
queryKey,
|
||||||
content: '',
|
highlighted = false
|
||||||
complete: false
|
}) => {
|
||||||
|
const copiableContent = useRef<{ content: string; complete: boolean }>({
|
||||||
|
content: '',
|
||||||
|
complete: false
|
||||||
|
})
|
||||||
|
|
||||||
|
const filtered =
|
||||||
|
notification.status &&
|
||||||
|
shouldFilter({
|
||||||
|
copiableContent,
|
||||||
|
status: notification.status,
|
||||||
|
queryKey
|
||||||
})
|
})
|
||||||
|
if (notification.status && filtered) {
|
||||||
|
return <TimelineFiltered phrase={filtered} />
|
||||||
|
}
|
||||||
|
|
||||||
const filtered =
|
const { colors } = useTheme()
|
||||||
notification.status &&
|
const instanceAccount = useSelector(getInstanceAccount, (prev, next) => prev?.id === next?.id)
|
||||||
shouldFilter({
|
const navigation = useNavigation<StackNavigationProp<TabLocalStackParamList>>()
|
||||||
copiableContent,
|
|
||||||
status: notification.status,
|
const actualAccount = notification.status ? notification.status.account : notification.account
|
||||||
queryKey
|
|
||||||
|
const onPress = useCallback(() => {
|
||||||
|
analytics('timeline_notification_press')
|
||||||
|
notification.status &&
|
||||||
|
navigation.push('Tab-Shared-Toot', {
|
||||||
|
toot: notification.status,
|
||||||
|
rootQueryKey: queryKey
|
||||||
})
|
})
|
||||||
if (notification.status && filtered) {
|
}, [])
|
||||||
return <TimelineFiltered phrase={filtered} />
|
|
||||||
}
|
|
||||||
|
|
||||||
const { colors } = useTheme()
|
|
||||||
const instanceAccount = useSelector(getInstanceAccount, (prev, next) => prev?.id === next?.id)
|
|
||||||
const navigation = useNavigation<StackNavigationProp<TabLocalStackParamList>>()
|
|
||||||
|
|
||||||
const actualAccount = notification.status ? notification.status.account : notification.account
|
|
||||||
|
|
||||||
const onPress = useCallback(() => {
|
|
||||||
analytics('timeline_notification_press')
|
|
||||||
notification.status &&
|
|
||||||
navigation.push('Tab-Shared-Toot', {
|
|
||||||
toot: notification.status,
|
|
||||||
rootQueryKey: queryKey
|
|
||||||
})
|
|
||||||
}, [])
|
|
||||||
|
|
||||||
|
const main = () => {
|
||||||
return (
|
return (
|
||||||
<TimelineContextMenu
|
<>
|
||||||
copiableContent={copiableContent}
|
{notification.type !== 'mention' ? (
|
||||||
status={notification.status}
|
<TimelineActioned
|
||||||
queryKey={queryKey}
|
action={notification.type}
|
||||||
>
|
account={notification.account}
|
||||||
<Pressable
|
notification
|
||||||
|
/>
|
||||||
|
) : null}
|
||||||
|
|
||||||
|
<View
|
||||||
style={{
|
style={{
|
||||||
padding: StyleConstants.Spacing.Global.PagePadding,
|
opacity:
|
||||||
backgroundColor: colors.backgroundDefault,
|
notification.type === 'follow' ||
|
||||||
paddingBottom: notification.status ? 0 : StyleConstants.Spacing.Global.PagePadding
|
notification.type === 'follow_request' ||
|
||||||
|
notification.type === 'mention' ||
|
||||||
|
notification.type === 'status'
|
||||||
|
? 1
|
||||||
|
: 0.5
|
||||||
}}
|
}}
|
||||||
onPress={onPress}
|
|
||||||
onLongPress={() => {}}
|
|
||||||
>
|
>
|
||||||
{notification.type !== 'mention' ? (
|
<View style={{ flex: 1, width: '100%', flexDirection: 'row' }}>
|
||||||
<TimelineActioned
|
<TimelineAvatar queryKey={queryKey} account={actualAccount} highlighted={highlighted} />
|
||||||
action={notification.type}
|
<TimelineHeaderNotification queryKey={queryKey} notification={notification} />
|
||||||
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 queryKey={queryKey} 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 ? (
|
||||||
<TimelineActions
|
<View
|
||||||
queryKey={queryKey}
|
style={{
|
||||||
status={notification.status}
|
paddingTop: highlighted ? StyleConstants.Spacing.S : 0,
|
||||||
highlighted={highlighted}
|
paddingLeft: highlighted ? 0 : StyleConstants.Avatar.M + StyleConstants.Spacing.S
|
||||||
accts={uniqBy(
|
}}
|
||||||
([notification.status.account] as Mastodon.Account[] & Mastodon.Mention[])
|
>
|
||||||
.concat(notification.status.mentions)
|
{notification.status.content.length > 0 ? (
|
||||||
.filter(d => d?.id !== instanceAccount?.id),
|
<TimelineContent status={notification.status} highlighted={highlighted} />
|
||||||
d => d?.id
|
) : null}
|
||||||
).map(d => d?.acct)}
|
{notification.status.poll ? (
|
||||||
reblog={false}
|
<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}
|
||||||
</Pressable>
|
</View>
|
||||||
</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}
|
||||||
|
</>
|
||||||
)
|
)
|
||||||
},
|
}
|
||||||
(prev, next) => isEqual(prev.notification, next.notification)
|
|
||||||
)
|
return Platform.OS === 'android' ? (
|
||||||
|
<Pressable
|
||||||
|
style={{
|
||||||
|
padding: StyleConstants.Spacing.Global.PagePadding,
|
||||||
|
backgroundColor: colors.backgroundDefault,
|
||||||
|
paddingBottom: notification.status ? 0 : StyleConstants.Spacing.Global.PagePadding
|
||||||
|
}}
|
||||||
|
onPress={onPress}
|
||||||
|
onLongPress={() => {}}
|
||||||
|
>
|
||||||
|
{main()}
|
||||||
|
</Pressable>
|
||||||
|
) : (
|
||||||
|
<TimelineContextMenu
|
||||||
|
copiableContent={copiableContent}
|
||||||
|
status={notification.status}
|
||||||
|
queryKey={queryKey}
|
||||||
|
>
|
||||||
|
<Pressable
|
||||||
|
style={{
|
||||||
|
padding: StyleConstants.Spacing.Global.PagePadding,
|
||||||
|
backgroundColor: colors.backgroundDefault,
|
||||||
|
paddingBottom: notification.status ? 0 : StyleConstants.Spacing.Global.PagePadding
|
||||||
|
}}
|
||||||
|
onPress={onPress}
|
||||||
|
onLongPress={() => {}}
|
||||||
|
>
|
||||||
|
{main()}
|
||||||
|
</Pressable>
|
||||||
|
</TimelineContextMenu>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
export default TimelineNotifications
|
export default TimelineNotifications
|
||||||
|
|
Loading…
Reference in New Issue