mirror of
https://github.com/tooot-app/app
synced 2025-04-19 04:37:24 +02:00
Fix remote toot not interactable
This commit is contained in:
parent
398f34d95d
commit
4a340fca8e
@ -11,7 +11,7 @@ import { usePreferencesQuery } from '@utils/queryHooks/preferences'
|
|||||||
import { StyleConstants } from '@utils/styles/constants'
|
import { StyleConstants } from '@utils/styles/constants'
|
||||||
import { isLargeDevice } from '@utils/styles/scaling'
|
import { isLargeDevice } from '@utils/styles/scaling'
|
||||||
import { chunk } from 'lodash'
|
import { chunk } from 'lodash'
|
||||||
import React, { useContext, useState } from 'react'
|
import React, { Fragment, useContext, useState } 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 StatusContext from '../Context'
|
import StatusContext from '../Context'
|
||||||
@ -72,14 +72,9 @@ const TimelineAttachment = () => {
|
|||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
if (
|
if (
|
||||||
attachment.preview_url?.endsWith('.jpg') ||
|
// https://docs.expo.dev/versions/unversioned/sdk/image/#supported-image-formats
|
||||||
attachment.preview_url?.endsWith('.jpeg') ||
|
attachment.preview_url?.match(/.(?:a?png|jpe?g|webp|avif|heic|gif|svg|ico|icns)$/i) ||
|
||||||
attachment.preview_url?.endsWith('.png') ||
|
attachment.remote_url?.match(/.(?:a?png|jpe?g|webp|avif|heic|gif|svg|ico|icns)$/i)
|
||||||
attachment.preview_url?.endsWith('.gif') ||
|
|
||||||
attachment.remote_url?.endsWith('.jpg') ||
|
|
||||||
attachment.remote_url?.endsWith('.jpeg') ||
|
|
||||||
attachment.remote_url?.endsWith('.png') ||
|
|
||||||
attachment.remote_url?.endsWith('.gif')
|
|
||||||
) {
|
) {
|
||||||
return {
|
return {
|
||||||
id: attachment.id,
|
id: attachment.id,
|
||||||
@ -186,6 +181,7 @@ const TimelineAttachment = () => {
|
|||||||
>
|
>
|
||||||
{chunk(status.media_attachments, 2).map((chunk, chunkIndex) => (
|
{chunk(status.media_attachments, 2).map((chunk, chunkIndex) => (
|
||||||
<View
|
<View
|
||||||
|
key={chunkIndex}
|
||||||
style={{
|
style={{
|
||||||
flex: 1,
|
flex: 1,
|
||||||
flexDirection: 'row',
|
flexDirection: 'row',
|
||||||
@ -195,7 +191,9 @@ const TimelineAttachment = () => {
|
|||||||
gap: StyleConstants.Spacing.XS
|
gap: StyleConstants.Spacing.XS
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{chunk.map((a, aIndex) => mapAttachmentType(a, chunkIndex * 2 + aIndex))}
|
{chunk.map((a, aIndex) => (
|
||||||
|
<Fragment key={aIndex}>{mapAttachmentType(a, chunkIndex * 2 + aIndex)}</Fragment>
|
||||||
|
))}
|
||||||
</View>
|
</View>
|
||||||
))}
|
))}
|
||||||
|
|
||||||
|
@ -42,6 +42,7 @@ export interface Props {
|
|||||||
'notifyOnChangeProps' | 'getNextPageParam' | 'getPreviousPageParam' | 'select' | 'onSuccess'
|
'notifyOnChangeProps' | 'getNextPageParam' | 'getPreviousPageParam' | 'select' | 'onSuccess'
|
||||||
>
|
>
|
||||||
disableRefresh?: boolean
|
disableRefresh?: boolean
|
||||||
|
refreshAutoRefetch?: boolean
|
||||||
disableInfinity?: boolean
|
disableInfinity?: boolean
|
||||||
readMarker?: 'read_marker_following'
|
readMarker?: 'read_marker_following'
|
||||||
customProps?: Partial<FlatListProps<any>>
|
customProps?: Partial<FlatListProps<any>>
|
||||||
@ -52,6 +53,7 @@ const Timeline: React.FC<Props> = ({
|
|||||||
queryKey,
|
queryKey,
|
||||||
queryOptions,
|
queryOptions,
|
||||||
disableRefresh = false,
|
disableRefresh = false,
|
||||||
|
refreshAutoRefetch = true,
|
||||||
disableInfinity = false,
|
disableInfinity = false,
|
||||||
readMarker = undefined,
|
readMarker = undefined,
|
||||||
customProps
|
customProps
|
||||||
@ -154,6 +156,7 @@ const Timeline: React.FC<Props> = ({
|
|||||||
if (
|
if (
|
||||||
curr === true &&
|
curr === true &&
|
||||||
prev === false &&
|
prev === false &&
|
||||||
|
refreshAutoRefetch &&
|
||||||
!isFetchingPrev.value &&
|
!isFetchingPrev.value &&
|
||||||
fetchingType.value === 0 &&
|
fetchingType.value === 0 &&
|
||||||
shouldAutoFetch.value &&
|
shouldAutoFetch.value &&
|
||||||
|
@ -4,6 +4,7 @@ import Icon from '@components/Icon'
|
|||||||
import CustomText from '@components/Text'
|
import CustomText from '@components/Text'
|
||||||
import Timeline from '@components/Timeline'
|
import Timeline from '@components/Timeline'
|
||||||
import SegmentedControl from '@react-native-segmented-control/segmented-control'
|
import SegmentedControl from '@react-native-segmented-control/segmented-control'
|
||||||
|
import { useScrollToTop } from '@react-navigation/native'
|
||||||
import { NativeStackScreenProps } from '@react-navigation/native-stack'
|
import { NativeStackScreenProps } from '@react-navigation/native-stack'
|
||||||
import apiGeneral from '@utils/api/general'
|
import apiGeneral from '@utils/api/general'
|
||||||
import { TabPublicStackParamList } from '@utils/navigation/navigators'
|
import { TabPublicStackParamList } from '@utils/navigation/navigators'
|
||||||
@ -114,11 +115,14 @@ const Explore = ({ route: { key: page } }: { route: { key: 'Explore' } }) => {
|
|||||||
</View>
|
</View>
|
||||||
)
|
)
|
||||||
|
|
||||||
|
useScrollToTop(flRef)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Timeline
|
<Timeline
|
||||||
flRef={flRef}
|
flRef={flRef}
|
||||||
queryKey={queryKey}
|
queryKey={queryKey}
|
||||||
disableRefresh={!remoteActive}
|
disableRefresh={!remoteActive}
|
||||||
|
refreshAutoRefetch={false}
|
||||||
customProps={{
|
customProps={{
|
||||||
ListHeaderComponent: (
|
ListHeaderComponent: (
|
||||||
<View
|
<View
|
||||||
@ -400,10 +404,17 @@ const Root: React.FC<NativeStackScreenProps<TabPublicStackParamList, 'Tab-Public
|
|||||||
{ key: 'LocalPublic', title: t('tabs.public.segments.federated') },
|
{ key: 'LocalPublic', title: t('tabs.public.segments.federated') },
|
||||||
{ key: 'Explore', title: t('tabs.public.segments.explore') }
|
{ key: 'Explore', title: t('tabs.public.segments.explore') }
|
||||||
])
|
])
|
||||||
|
const [remoteActive] = useGlobalStorage.string('remote.active')
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const page = segments[segment]
|
const page = segments[segment]
|
||||||
page && navigation.setParams({ queryKey: ['Timeline', { page }] })
|
page &&
|
||||||
}, [segment])
|
navigation.setParams({
|
||||||
|
queryKey: [
|
||||||
|
'Timeline',
|
||||||
|
{ page, ...(page === 'Explore' && remoteActive && { domain: remoteActive }) }
|
||||||
|
]
|
||||||
|
})
|
||||||
|
}, [segment, remoteActive])
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
navigation.setOptions({
|
navigation.setOptions({
|
||||||
|
@ -29,7 +29,7 @@ const TabSharedToot: React.FC<TabSharedStackScreenProps<'Tab-Shared-Toot'>> = ({
|
|||||||
const { colors } = useTheme()
|
const { colors } = useTheme()
|
||||||
const { t } = useTranslation(['componentTimeline', 'screenTabs'])
|
const { t } = useTranslation(['componentTimeline', 'screenTabs'])
|
||||||
|
|
||||||
const [hasRemoteContent, setHasRemoteContent] = useState<boolean>(false)
|
const [hasRemoteContent, setHasRemoteContent] = useState<boolean>(toot._remote || false)
|
||||||
const queryKey: { local: QueryKeyTimeline; remote: QueryKeyTimeline } = {
|
const queryKey: { local: QueryKeyTimeline; remote: QueryKeyTimeline } = {
|
||||||
local: ['Timeline', { page: 'Toot', toot: toot.id, remote: false }],
|
local: ['Timeline', { page: 'Toot', toot: toot.id, remote: false }],
|
||||||
remote: ['Timeline', { page: 'Toot', toot: toot.id, remote: true }]
|
remote: ['Timeline', { page: 'Toot', toot: toot.id, remote: true }]
|
||||||
@ -70,7 +70,7 @@ const TabSharedToot: React.FC<TabSharedStackScreenProps<'Tab-Shared-Toot'>> = ({
|
|||||||
headerLeft: () => <HeaderLeft onPress={() => navigation.goBack()} />,
|
headerLeft: () => <HeaderLeft onPress={() => navigation.goBack()} />,
|
||||||
headerBackVisible: false
|
headerBackVisible: false
|
||||||
})
|
})
|
||||||
navigation.setParams({ toot, queryKey: queryKey.local })
|
navigation.setParams({ queryKey: queryKey.local })
|
||||||
}, [hasRemoteContent])
|
}, [hasRemoteContent])
|
||||||
|
|
||||||
const PREV_PER_BATCH = 1
|
const PREV_PER_BATCH = 1
|
||||||
@ -236,12 +236,15 @@ const TabSharedToot: React.FC<TabSharedStackScreenProps<'Tab-Shared-Toot'>> = ({
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((query.data?.pages[0].body.length || 0) < data.length) {
|
if ((query.data?.pages[0].body.length || 0) <= data.length) {
|
||||||
|
if (!hasRemoteContent && (query.data?.pages[0].body.length || 0) <= data.length) {
|
||||||
|
setHasRemoteContent(true)
|
||||||
|
}
|
||||||
|
|
||||||
queryClient.cancelQueries(queryKey.local)
|
queryClient.cancelQueries(queryKey.local)
|
||||||
queryClient.setQueryData<{ pages: { body: Mastodon.Status[] }[] }>(
|
queryClient.setQueryData<{ pages: { body: Mastodon.Status[] }[] }>(
|
||||||
queryKey.local,
|
queryKey.local,
|
||||||
old => {
|
old => {
|
||||||
setHasRemoteContent(true)
|
|
||||||
return {
|
return {
|
||||||
pages: [
|
pages: [
|
||||||
{
|
{
|
||||||
@ -350,7 +353,7 @@ const TabSharedToot: React.FC<TabSharedStackScreenProps<'Tab-Shared-Toot'>> = ({
|
|||||||
) : null}
|
) : null}
|
||||||
<TimelineDefault
|
<TimelineDefault
|
||||||
item={item}
|
item={item}
|
||||||
queryKey={item._remote ? queryKey.remote : queryKey.local}
|
queryKey={queryKey.local}
|
||||||
highlighted={toot.id === item.id}
|
highlighted={toot.id === item.id}
|
||||||
suppressSpoiler={
|
suppressSpoiler={
|
||||||
toot.id !== item.id &&
|
toot.id !== item.id &&
|
||||||
|
Loading…
x
Reference in New Issue
Block a user