Improve auto fetch

This commit is contained in:
xmflsct 2023-02-08 19:22:20 +01:00
parent 724cd76647
commit 48481a4cd5
10 changed files with 30 additions and 23 deletions

View File

@ -11,6 +11,7 @@ import log from '@utils/startup/log'
import netInfo from '@utils/startup/netInfo'
import push from '@utils/startup/push'
import sentry from '@utils/startup/sentry'
import { GLOBAL } from '@utils/storage'
import { getGlobalStorage, setAccount, setGlobalStorage } from '@utils/storage/actions'
import { migrateFromAsyncStorage, versionStorageGlobal } from '@utils/storage/migrations/toMMKV'
import ThemeManager from '@utils/styles/ThemeManager'
@ -24,10 +25,6 @@ import { enableFreeze } from 'react-native-screens'
import i18n from './i18n'
import Screens from './screens'
export const GLOBAL: { connect?: boolean } = {
connect: undefined
}
Platform.select({
android: LogBox.ignoreLogs(['Setting a timer for a long period of time'])
})

View File

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

View File

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

View File

@ -16,8 +16,8 @@ import { setAccountStorage, useAccountStorage, useGlobalStorage } from '@utils/s
import { StyleConstants } from '@utils/styles/constants'
import layoutAnimation from '@utils/styles/layoutAnimation'
import { useTheme } from '@utils/styles/ThemeManager'
import * as Crypto from 'expo-crypto'
import * as Notifications from 'expo-notifications'
import * as Random from 'expo-random'
import * as WebBrowser from 'expo-web-browser'
import React, { useEffect, useState } from 'react'
import { useTranslation } from 'react-i18next'
@ -173,7 +173,7 @@ const TabMePush: React.FC = () => {
// Fix a bug for some users of v4.8.0
let authKey = push.key
if (push.key?.length <= 10) {
authKey = fromByteArray(Random.getRandomBytes(16))
authKey = fromByteArray(Crypto.getRandomBytes(16))
}
// Turning on
const randomPath = (Math.random() + 1).toString(36).substring(2)

View File

@ -5,13 +5,13 @@ import { LOCALES } from '@i18n/locales'
import { useNavigation } from '@react-navigation/native'
import { connectVerify } from '@utils/api/helpers/connect'
import { androidActionSheetStyles } from '@utils/helpers/androidActionSheetStyles'
import { GLOBAL } from '@utils/storage'
import { useGlobalStorage } from '@utils/storage/actions'
import { useTheme } from '@utils/styles/ThemeManager'
import * as Localization from 'expo-localization'
import React, { useEffect, useState } from 'react'
import { useTranslation } from 'react-i18next'
import { Linking, Platform } from 'react-native'
import { GLOBAL } from '../../../../App'
import { mapFontsizeToName } from '../SettingsFontsize'
const SettingsApp: React.FC = () => {

View File

@ -1,5 +1,5 @@
import { GLOBAL } from '@utils/storage'
import axios from 'axios'
import { GLOBAL } from '../../App'
import { ctx, handleError, PagedResponse, parseHeaderLinks, userAgent } from './helpers'
import { CONNECT_DOMAIN } from './helpers/connect'

View File

@ -1,9 +1,9 @@
import { mapEnvironment } from '@utils/helpers/checkEnvironment'
import { GLOBAL } from '@utils/storage'
import { setGlobalStorage } from '@utils/storage/actions'
import axios from 'axios'
import parse from 'url-parse'
import { userAgent } from '.'
import { GLOBAL } from '../../../App'
const list = [
'n61owz4leck',

View File

@ -1,10 +1,10 @@
import * as Sentry from '@sentry/react-native'
import { GLOBAL } from '@utils/storage'
import { setGlobalStorage } from '@utils/storage/actions'
import chalk from 'chalk'
import Constants from 'expo-constants'
import { Platform } from 'react-native'
import parse from 'url-parse'
import { GLOBAL } from '../../../App'
const userAgent = {
'User-Agent': `tooot/${Constants.expoConfig?.version} ${Platform.OS}/${Platform.Version}`

View File

@ -1,7 +1,7 @@
import { GLOBAL } from '@utils/storage'
import { getAccountDetails } from '@utils/storage/actions'
import { StorageGlobal } from '@utils/storage/global'
import axios, { AxiosRequestConfig } from 'axios'
import { GLOBAL } from '../../App'
import { ctx, handleError, PagedResponse, parseHeaderLinks, userAgent } from './helpers'
import { CONNECT_DOMAIN } from './helpers/connect'

View File

@ -4,3 +4,7 @@ import { MMKV } from 'react-native-mmkv'
export const storage: { global: MMKV; account?: MMKV } = { global: new MMKV(), account: undefined }
export const secureStorage = createSecureStore()
export const GLOBAL: { connect?: boolean } = {
connect: undefined
}