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 2023-02-24 13:54:27 +01:00
parent b1a796d3f1
commit 04a56edcf4
5 changed files with 22 additions and 24 deletions

View File

@ -61,7 +61,7 @@ const GracefullyImage = ({
placeholderContentFit='cover' placeholderContentFit='cover'
placeholder={sources.blurhash || connectMedia(sources.preview)} placeholder={sources.blurhash || connectMedia(sources.preview)}
source={hidden ? undefined : connectMedia(source)} source={hidden ? undefined : connectMedia(source)}
{...((!withoutTransition || !reduceMotionEnabled) && { transition: { duration: 120 } })} {...(!withoutTransition && !reduceMotionEnabled && { transition: { duration: 120 } })}
style={{ flex: 1, ...imageStyle }} style={{ flex: 1, ...imageStyle }}
onError={() => { onError={() => {
if ( if (

View File

@ -17,13 +17,8 @@ import { Pressable, View } from 'react-native'
import StatusContext from '../Context' import StatusContext from '../Context'
const TimelineAttachment = () => { const TimelineAttachment = () => {
const { status, disableDetails } = useContext(StatusContext) const { status, spoilerHidden, disableDetails } = useContext(StatusContext)
if ( if (!status || !Array.isArray(status.media_attachments) || !status.media_attachments.length)
!status ||
disableDetails ||
!Array.isArray(status.media_attachments) ||
!status.media_attachments.length
)
return null return null
const { t } = useTranslation('componentTimeline') const { t } = useTranslation('componentTimeline')
@ -170,6 +165,8 @@ const TimelineAttachment = () => {
} }
} }
if (spoilerHidden || disableDetails) return null
return ( return (
<View style={{ marginTop: StyleConstants.Spacing.M, ...(isLargeDevice && { maxWidth: 375 }) }}> <View style={{ marginTop: StyleConstants.Spacing.M, ...(isLargeDevice && { maxWidth: 375 }) }}>
<View style={{ gap: StyleConstants.Spacing.XS }}> <View style={{ gap: StyleConstants.Spacing.XS }}>

View File

@ -167,12 +167,12 @@ const Timeline: React.FC<Props> = ({
} }
) )
const latestMarker = useRef<string>() const latestMarker = useRef<string>('')
const updateMarkers = useCallback( const updateMarkers = useCallback(
throttle(() => { throttle(() => {
if (readMarker) { if (readMarker) {
const currentMarker = getAccountStorage.string(readMarker) || '0' const currentMarker = getAccountStorage.string(readMarker) || '0'
if ((latestMarker.current || '0') > currentMarker) { if (latestMarker.current > currentMarker) {
setAccountStorage([{ key: readMarker, value: latestMarker.current }]) setAccountStorage([{ key: readMarker, value: latestMarker.current }])
} else { } else {
// setAccountStorage([{ key: readMarker, value: '105250709762254246' }]) // setAccountStorage([{ key: readMarker, value: '105250709762254246' }])
@ -183,9 +183,12 @@ const Timeline: React.FC<Props> = ({
) )
readMarker && readMarker &&
useEffect(() => { useEffect(() => {
const unsubscribe = navigation.addListener('blur', () => const unsubscribe = navigation.addListener('blur', () => {
const currentMarker = getAccountStorage.string(readMarker) || '0'
if (latestMarker.current > currentMarker) {
setAccountStorage([{ key: readMarker, value: latestMarker.current }]) setAccountStorage([{ key: readMarker, value: latestMarker.current }])
) }
})
return unsubscribe return unsubscribe
}, []) }, [])
const viewabilityConfigCallbackPairs = useRef< const viewabilityConfigCallbackPairs = useRef<

View File

@ -124,6 +124,8 @@ const Explore = ({ route: { key: page } }: { route: { key: 'Explore' } }) => {
disableRefresh={!remoteActive} disableRefresh={!remoteActive}
refreshAutoRefetch={false} refreshAutoRefetch={false}
customProps={{ customProps={{
stickyHeaderIndices: [0],
stickyHeaderHiddenOnScroll: true,
ListHeaderComponent: ( ListHeaderComponent: (
<View <View
style={{ backgroundColor: colors.backgroundDefault }} style={{ backgroundColor: colors.backgroundDefault }}
@ -279,7 +281,8 @@ const Explore = ({ route: { key: page } }: { route: { key: 'Explore' } }) => {
alignItems: 'center', alignItems: 'center',
justifyContent: 'center', justifyContent: 'center',
gap: StyleConstants.Spacing.XS, gap: StyleConstants.Spacing.XS,
paddingTop: StyleConstants.Spacing.M paddingTop: StyleConstants.Spacing.S,
paddingBottom: StyleConstants.Spacing.M
}} }}
> >
<CustomText <CustomText

View File

@ -35,7 +35,7 @@ const TabSharedToot: React.FC<TabSharedStackScreenProps<'Tab-Shared-Toot'>> = ({
remote: ['Timeline', { page: 'Toot', toot: toot.id, remote: true }] remote: ['Timeline', { page: 'Toot', toot: toot.id, remote: true }]
} }
const flRef = useRef<FlatList<Mastodon.Status & { _level?: number; key?: string }>>(null) const flRef = useRef<FlatList<Mastodon.Status & { _level?: number }>>(null)
useEffect(() => { useEffect(() => {
navigation.setOptions({ navigation.setOptions({
@ -74,7 +74,7 @@ const TabSharedToot: React.FC<TabSharedStackScreenProps<'Tab-Shared-Toot'>> = ({
}, [hasRemoteContent]) }, [hasRemoteContent])
const PREV_PER_BATCH = 1 const PREV_PER_BATCH = 1
const ancestorsCache = useRef<(Mastodon.Status & { _level?: number; key?: string })[]>() const ancestorsCache = useRef<(Mastodon.Status & { _level?: number })[]>()
const loaded = useRef<boolean>(false) const loaded = useRef<boolean>(false)
const prependContent = async () => { const prependContent = async () => {
loaded.current = true loaded.current = true
@ -126,7 +126,7 @@ const TabSharedToot: React.FC<TabSharedStackScreenProps<'Tab-Shared-Toot'>> = ({
['public', 'unlisted'].includes(toot.visibility) && ['public', 'unlisted'].includes(toot.visibility) &&
match?.domain !== getAccountStorage.string('auth.domain') match?.domain !== getAccountStorage.string('auth.domain')
const query = useQuery<{ const query = useQuery<{
pages: { body: (Mastodon.Status & { _level?: number; key?: string })[] }[] pages: { body: (Mastodon.Status & { _level?: number })[] }[]
}>( }>(
queryKey.local, queryKey.local,
async () => { async () => {
@ -160,7 +160,6 @@ const TabSharedToot: React.FC<TabSharedStackScreenProps<'Tab-Shared-Toot'>> = ({
} }
}, },
{ {
placeholderData: { pages: [{ body: [{ ...toot, _level: 0, key: `${toot.id}_cache` }] }] },
enabled: !toot._remote, enabled: !toot._remote,
staleTime: 0, staleTime: 0,
refetchOnMount: true, refetchOnMount: true,
@ -255,11 +254,7 @@ const TabSharedToot: React.FC<TabSharedStackScreenProps<'Tab-Shared-Toot'>> = ({
body: data.map(remote => { body: data.map(remote => {
const localMatch = old?.pages[0].body.find(local => local.uri === remote.uri) const localMatch = old?.pages[0].body.find(local => local.uri === remote.uri)
if (localMatch) { if (localMatch) {
return { return { ...localMatch, _level: remote._level }
...localMatch,
_level: remote._level,
key: `${localMatch.id}_remote`
}
} else { } else {
return appendRemote.status(remote) return appendRemote.status(remote)
} }
@ -285,7 +280,7 @@ const TabSharedToot: React.FC<TabSharedStackScreenProps<'Tab-Shared-Toot'>> = ({
<FlatList <FlatList
ref={flRef} ref={flRef}
data={query.data?.pages?.[0].body} data={query.data?.pages?.[0].body}
extraData={query.dataUpdatedAt} keyExtractor={(item, index) => `${item.id}_${index}`}
renderItem={({ item, index }) => { renderItem={({ item, index }) => {
const prev = query.data?.pages[0].body[index - 1]?._level || 0 const prev = query.data?.pages[0].body[index - 1]?._level || 0
const curr = item._level || 0 const curr = item._level || 0