1
0
mirror of https://github.com/tooot-app/app synced 2025-06-05 22:19:13 +02:00
This commit is contained in:
xmflsct
2022-12-14 23:37:41 +01:00
parent 7f8a8de898
commit 4a35e910c1
23 changed files with 425 additions and 302 deletions

View File

@ -1,6 +1,4 @@
import Icon from '@components/Icon'
import CustomText from '@components/Text'
import { StyleConstants } from '@utils/styles/constants'
import { useTheme } from '@utils/styles/ThemeManager'
import React from 'react'
import { View } from 'react-native'
@ -9,16 +7,10 @@ export interface Props {
content?: string
inverted?: boolean
onPress?: () => void
dropdown?: boolean
}
// Used for Android mostly
const HeaderCenter: React.FC<Props> = ({
content,
inverted = false,
onPress,
dropdown = false
}) => {
const HeaderCenter: React.FC<Props> = ({ content, inverted = false, onPress }) => {
const { colors } = useTheme()
return (
@ -33,13 +25,6 @@ const HeaderCenter: React.FC<Props> = ({
children={content}
{...(onPress && { onPress })}
/>
<Icon
name='ChevronDown'
size={StyleConstants.Font.Size.M}
color={colors.primaryDefault}
style={{ marginLeft: StyleConstants.Spacing.XS, opacity: dropdown ? undefined : 0 }}
strokeWidth={3}
/>
</View>
)
}

View File

@ -11,6 +11,7 @@ export interface Props {
fill?: string
strokeWidth?: number
style?: StyleProp<ViewStyle>
crossOut?: boolean
}
const Icon: React.FC<Props> = ({
@ -20,7 +21,8 @@ const Icon: React.FC<Props> = ({
color,
fill,
strokeWidth = 2,
style
style,
crossOut = false
}) => {
return (
<View
@ -42,6 +44,17 @@ const Icon: React.FC<Props> = ({
fill,
strokeWidth
})}
{crossOut ? (
<View
style={{
position: 'absolute',
transform: [{ rotate: '45deg' }],
width: size * 1.35,
borderBottomColor: color,
borderBottomWidth: strokeWidth
}}
/>
) : null}
</View>
)
}

View File

@ -196,7 +196,7 @@ const ParseHTML = React.memo(
const navigation = useNavigation<StackNavigationProp<TabLocalStackParamList>>()
const route = useRoute()
const { colors, theme } = useTheme()
const { t, i18n } = useTranslation('componentParse')
const { t } = useTranslation('componentParse')
if (!expandHint) {
expandHint = t('HTML.defaultHint')
}
@ -304,7 +304,7 @@ const ParseHTML = React.memo(
</View>
)
},
[theme, i18n.language]
[theme]
)
return (

View File

@ -30,8 +30,8 @@ const RelationshipOutgoing = React.memo(
haptics('Success')
queryClient.setQueryData<Mastodon.Relationship[]>(queryKeyRelationship, [res])
if (action === 'block') {
const queryKey: QueryKeyTimeline = ['Timeline', { page: 'Following' }]
queryClient.invalidateQueries(queryKey)
const queryKey = ['Timeline', { page: 'Following' }]
queryClient.invalidateQueries({ queryKey, exact: false })
}
},
onError: (err: any, { payload: { action } }) => {

View File

@ -45,6 +45,7 @@ export const shouldFilter = ({
status: Mastodon.Status
queryKey: QueryKeyTimeline
}): string | null => {
const page = queryKey[1]
const instance = getInstance(store.getState())
const ownAccount = getInstanceAccount(store.getState())?.id === status.account?.id
@ -93,11 +94,11 @@ export const shouldFilter = ({
}
}
switch (queryKey[1].page) {
switch (page.page) {
case 'Following':
case 'Local':
case 'List':
case 'Account_Default':
case 'Account':
if (filter.context.includes('home')) {
checkFilter(filter)
}

View File

@ -1,5 +1,4 @@
import menuAccount from '@components/contextMenu/account'
import menuInstance from '@components/contextMenu/instance'
import menuShare from '@components/contextMenu/share'
import menuStatus from '@components/contextMenu/status'
import Icon from '@components/Icon'
@ -31,7 +30,6 @@ const TimelineHeaderAndroid: React.FC = () => {
queryKey
})
const mStatus = menuStatus({ status, queryKey, rootQueryKey })
const mInstance = menuInstance({ status, queryKey, rootQueryKey })
return (
<View style={{ position: 'absolute', top: 0, right: 0 }}>
@ -77,16 +75,6 @@ const TimelineHeaderAndroid: React.FC = () => {
))}
</DropdownMenu.Group>
))}
{mInstance.map((mGroup, index) => (
<DropdownMenu.Group key={index}>
{mGroup.map(menu => (
<DropdownMenu.Item key={menu.key} {...menu.item}>
<DropdownMenu.ItemTitle children={menu.title} />
</DropdownMenu.Item>
))}
</DropdownMenu.Group>
))}
</DropdownMenu.Content>
</DropdownMenu.Root>
) : null}

View File

@ -1,5 +1,4 @@
import menuAccount from '@components/contextMenu/account'
import menuInstance from '@components/contextMenu/instance'
import menuShare from '@components/contextMenu/share'
import menuStatus from '@components/contextMenu/status'
import Icon from '@components/Icon'
@ -38,7 +37,6 @@ const TimelineHeaderDefault: React.FC = () => {
queryKey
})
const mStatus = menuStatus({ status, queryKey, rootQueryKey })
const mInstance = menuInstance({ status, queryKey, rootQueryKey })
return (
<View style={{ flex: 1, flexDirection: 'row' }}>
@ -116,17 +114,6 @@ const TimelineHeaderDefault: React.FC = () => {
))}
</DropdownMenu.Group>
))}
{mInstance.map((mGroup, index) => (
<DropdownMenu.Group key={index}>
{mGroup.map(menu => (
<DropdownMenu.Item key={menu.key} {...menu.item}>
<DropdownMenu.ItemTitle children={menu.title} />
<DropdownMenu.ItemIcon iosIconName={menu.icon} />
</DropdownMenu.Item>
))}
</DropdownMenu.Group>
))}
</DropdownMenu.Content>
</DropdownMenu.Root>
</Pressable>

View File

@ -33,7 +33,7 @@ const TimelinePoll: React.FC = () => {
const poll = status.poll
const { colors, theme } = useTheme()
const { t, i18n } = useTranslation('componentTimeline')
const { t } = useTranslation('componentTimeline')
const [allOptions, setAllOptions] = useState(new Array(status.poll.options.length).fill(false))
@ -127,7 +127,7 @@ const TimelinePoll: React.FC = () => {
)
}
}
}, [theme, i18n.language, poll.expired, poll.voted, allOptions, mutation.isLoading])
}, [theme, poll.expired, poll.voted, allOptions, mutation.isLoading])
const isSelected = useCallback(
(index: number): string =>

View File

@ -50,7 +50,7 @@ const menuAccount = ({
setEnabled(true)
}
}, [openChange, enabled])
const { data, isFetching } = useRelationshipQuery({ id: account.id, options: { enabled } })
const { data, isFetched } = useRelationshipQuery({ id: account.id, options: { enabled } })
const queryClient = useQueryClient()
const timelineMutation = useTimelineMutation({
@ -99,8 +99,8 @@ const menuAccount = ({
haptics('Success')
queryClient.setQueryData<Mastodon.Relationship[]>(queryKeyRelationship, [res])
if (action === 'block') {
const queryKey: QueryKeyTimeline = ['Timeline', { page: 'Following' }]
queryClient.invalidateQueries(queryKey)
const queryKey = ['Timeline', { page: 'Following' }]
queryClient.invalidateQueries({ queryKey, exact: false })
}
},
onError: (err: any, { payload: { action } }) => {
@ -131,7 +131,7 @@ const menuAccount = ({
type: 'outgoing',
payload: { action: 'follow', state: !data?.requested ? data.following : true }
}),
disabled: !data || isFetching,
disabled: !data || !isFetched,
destructive: false,
hidden: false
},
@ -152,9 +152,9 @@ const menuAccount = ({
key: 'account-list',
item: {
onSelect: () => navigation.navigate('Tab-Shared-Account-In-Lists', { account }),
disabled: Platform.OS !== 'android' ? !data || isFetching : false,
disabled: Platform.OS !== 'android' ? !data || !isFetched : false,
destructive: false,
hidden: isFetching ? false : !data?.following
hidden: !isFetched || !data?.following
},
title: t('account.inLists'),
icon: 'checklist'
@ -169,7 +169,7 @@ const menuAccount = ({
id: account.id,
payload: { property: 'mute', currentValue: data?.muting }
}),
disabled: Platform.OS !== 'android' ? !data || isFetching : false,
disabled: Platform.OS !== 'android' ? !data || !isFetched : false,
destructive: false,
hidden: false
},
@ -192,7 +192,7 @@ const menuAccount = ({
id: account.id,
payload: { property: 'block', currentValue: data?.blocking }
}),
disabled: Platform.OS !== 'android' ? !data || isFetching : false,
disabled: Platform.OS !== 'android' ? !data || !isFetched : false,
destructive: !data?.blocking,
hidden: false
},