mirror of
https://github.com/tooot-app/app
synced 2025-06-05 22:19:13 +02:00
Improve auto fetch
This commit is contained in:
@@ -19,8 +19,8 @@ import {
|
||||
import { StyleConstants } from '@utils/styles/constants'
|
||||
import { useTheme } from '@utils/styles/ThemeManager'
|
||||
import * as AuthSession from 'expo-auth-session'
|
||||
import * as Crypto from 'expo-crypto'
|
||||
import { Image } from 'expo-image'
|
||||
import * as Random from 'expo-random'
|
||||
import * as WebBrowser from 'expo-web-browser'
|
||||
import { debounce } from 'lodash'
|
||||
import React, { RefObject, useCallback, useState } from 'react'
|
||||
@@ -162,7 +162,7 @@ const ComponentInstance: React.FC<Props> = ({
|
||||
'admin.sign_up': false,
|
||||
'admin.report': false
|
||||
},
|
||||
key: fromByteArray(Random.getRandomBytes(16))
|
||||
key: fromByteArray(Crypto.getRandomBytes(16))
|
||||
},
|
||||
page_local: {
|
||||
showBoosts: true,
|
||||
@@ -233,7 +233,7 @@ const ComponentInstance: React.FC<Props> = ({
|
||||
<View style={{ flexDirection: 'row' }}>
|
||||
<Image
|
||||
source={require('assets/images/welcome.png')}
|
||||
style={{ resizeMode: 'contain', flex: 1, aspectRatio: 16 / 9 }}
|
||||
style={{ flex: 1, aspectRatio: 16 / 9 }}
|
||||
/>
|
||||
</View>
|
||||
) : null}
|
||||
|
||||
@@ -134,15 +134,6 @@ const Timeline: React.FC<Props> = ({
|
||||
{
|
||||
onScroll: ({ contentOffset: { y } }) => {
|
||||
scrollY.value = y
|
||||
if (
|
||||
y < 300 &&
|
||||
!isFetchingPrev.value &&
|
||||
fetchingType.value === 0 &&
|
||||
shouldAutoFetch.value &&
|
||||
Platform.OS === 'ios'
|
||||
) {
|
||||
fetchingType.value = 1
|
||||
}
|
||||
},
|
||||
onEndDrag: ({ contentOffset: { y } }) => {
|
||||
if (!disableRefresh && !isFetching) {
|
||||
@@ -157,6 +148,21 @@ const Timeline: React.FC<Props> = ({
|
||||
},
|
||||
[isFetching]
|
||||
)
|
||||
useAnimatedReaction(
|
||||
() => scrollY.value < 600,
|
||||
(curr, prev) => {
|
||||
if (
|
||||
curr === true &&
|
||||
prev === false &&
|
||||
!isFetchingPrev.value &&
|
||||
fetchingType.value === 0 &&
|
||||
shouldAutoFetch.value &&
|
||||
Platform.OS === 'ios'
|
||||
) {
|
||||
fetchingType.value = 1
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
const latestMarker = useRef<string>()
|
||||
const updateMarkers = useCallback(
|
||||
|
||||
Reference in New Issue
Block a user