Android does not support true context menu anyway, thus removing per toot component.
This commit is contained in:
xmflsct 2022-11-20 14:41:41 +01:00
parent bf8826fec4
commit fbfae52627
3 changed files with 140 additions and 114 deletions

View File

@ -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",

View File

@ -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}

View File

@ -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,8 +29,11 @@ export interface Props {
highlighted?: boolean highlighted?: boolean
} }
const TimelineNotifications = React.memo( const TimelineNotifications: React.FC<Props> = ({
({ notification, queryKey, highlighted = false }: Props) => { notification,
queryKey,
highlighted = false
}) => {
const copiableContent = useRef<{ content: string; complete: boolean }>({ const copiableContent = useRef<{ content: string; complete: boolean }>({
content: '', content: '',
complete: false complete: false
@ -62,21 +65,9 @@ const TimelineNotifications = React.memo(
}) })
}, []) }, [])
const main = () => {
return ( return (
<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={() => {}}
>
{notification.type !== 'mention' ? ( {notification.type !== 'mention' ? (
<TimelineActioned <TimelineActioned
action={notification.type} action={notification.type}
@ -97,11 +88,7 @@ const TimelineNotifications = React.memo(
}} }}
> >
<View style={{ flex: 1, width: '100%', flexDirection: 'row' }}> <View style={{ flex: 1, width: '100%', flexDirection: 'row' }}>
<TimelineAvatar <TimelineAvatar queryKey={queryKey} account={actualAccount} highlighted={highlighted} />
queryKey={queryKey}
account={actualAccount}
highlighted={highlighted}
/>
<TimelineHeaderNotification queryKey={queryKey} notification={notification} /> <TimelineHeaderNotification queryKey={queryKey} notification={notification} />
</View> </View>
@ -147,11 +134,41 @@ const TimelineNotifications = React.memo(
reblog={false} reblog={false}
/> />
) : null} ) : null}
</>
)
}
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> </Pressable>
</TimelineContextMenu> </TimelineContextMenu>
) )
}, }
(prev, next) => isEqual(prev.notification, next.notification)
)
export default TimelineNotifications export default TimelineNotifications