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:
		| @@ -11,6 +11,7 @@ import log from '@utils/startup/log' | |||||||
| import netInfo from '@utils/startup/netInfo' | import netInfo from '@utils/startup/netInfo' | ||||||
| import push from '@utils/startup/push' | import push from '@utils/startup/push' | ||||||
| import sentry from '@utils/startup/sentry' | import sentry from '@utils/startup/sentry' | ||||||
|  | import { GLOBAL } from '@utils/storage' | ||||||
| import { getGlobalStorage, setAccount, setGlobalStorage } from '@utils/storage/actions' | import { getGlobalStorage, setAccount, setGlobalStorage } from '@utils/storage/actions' | ||||||
| import { migrateFromAsyncStorage, versionStorageGlobal } from '@utils/storage/migrations/toMMKV' | import { migrateFromAsyncStorage, versionStorageGlobal } from '@utils/storage/migrations/toMMKV' | ||||||
| import ThemeManager from '@utils/styles/ThemeManager' | import ThemeManager from '@utils/styles/ThemeManager' | ||||||
| @@ -24,10 +25,6 @@ import { enableFreeze } from 'react-native-screens' | |||||||
| import i18n from './i18n' | import i18n from './i18n' | ||||||
| import Screens from './screens' | import Screens from './screens' | ||||||
|  |  | ||||||
| export const GLOBAL: { connect?: boolean } = { |  | ||||||
|   connect: undefined |  | ||||||
| } |  | ||||||
|  |  | ||||||
| Platform.select({ | Platform.select({ | ||||||
|   android: LogBox.ignoreLogs(['Setting a timer for a long period of time']) |   android: LogBox.ignoreLogs(['Setting a timer for a long period of time']) | ||||||
| }) | }) | ||||||
|   | |||||||
| @@ -19,8 +19,8 @@ import { | |||||||
| import { StyleConstants } from '@utils/styles/constants' | import { StyleConstants } from '@utils/styles/constants' | ||||||
| import { useTheme } from '@utils/styles/ThemeManager' | import { useTheme } from '@utils/styles/ThemeManager' | ||||||
| import * as AuthSession from 'expo-auth-session' | import * as AuthSession from 'expo-auth-session' | ||||||
|  | import * as Crypto from 'expo-crypto' | ||||||
| import { Image } from 'expo-image' | import { Image } from 'expo-image' | ||||||
| import * as Random from 'expo-random' |  | ||||||
| import * as WebBrowser from 'expo-web-browser' | import * as WebBrowser from 'expo-web-browser' | ||||||
| import { debounce } from 'lodash' | import { debounce } from 'lodash' | ||||||
| import React, { RefObject, useCallback, useState } from 'react' | import React, { RefObject, useCallback, useState } from 'react' | ||||||
| @@ -162,7 +162,7 @@ const ComponentInstance: React.FC<Props> = ({ | |||||||
|               'admin.sign_up': false, |               'admin.sign_up': false, | ||||||
|               'admin.report': false |               'admin.report': false | ||||||
|             }, |             }, | ||||||
|             key: fromByteArray(Random.getRandomBytes(16)) |             key: fromByteArray(Crypto.getRandomBytes(16)) | ||||||
|           }, |           }, | ||||||
|           page_local: { |           page_local: { | ||||||
|             showBoosts: true, |             showBoosts: true, | ||||||
| @@ -233,7 +233,7 @@ const ComponentInstance: React.FC<Props> = ({ | |||||||
|         <View style={{ flexDirection: 'row' }}> |         <View style={{ flexDirection: 'row' }}> | ||||||
|           <Image |           <Image | ||||||
|             source={require('assets/images/welcome.png')} |             source={require('assets/images/welcome.png')} | ||||||
|             style={{ resizeMode: 'contain', flex: 1, aspectRatio: 16 / 9 }} |             style={{ flex: 1, aspectRatio: 16 / 9 }} | ||||||
|           /> |           /> | ||||||
|         </View> |         </View> | ||||||
|       ) : null} |       ) : null} | ||||||
|   | |||||||
| @@ -134,15 +134,6 @@ const Timeline: React.FC<Props> = ({ | |||||||
|     { |     { | ||||||
|       onScroll: ({ contentOffset: { y } }) => { |       onScroll: ({ contentOffset: { y } }) => { | ||||||
|         scrollY.value = y |         scrollY.value = y | ||||||
|         if ( |  | ||||||
|           y < 300 && |  | ||||||
|           !isFetchingPrev.value && |  | ||||||
|           fetchingType.value === 0 && |  | ||||||
|           shouldAutoFetch.value && |  | ||||||
|           Platform.OS === 'ios' |  | ||||||
|         ) { |  | ||||||
|           fetchingType.value = 1 |  | ||||||
|         } |  | ||||||
|       }, |       }, | ||||||
|       onEndDrag: ({ contentOffset: { y } }) => { |       onEndDrag: ({ contentOffset: { y } }) => { | ||||||
|         if (!disableRefresh && !isFetching) { |         if (!disableRefresh && !isFetching) { | ||||||
| @@ -157,6 +148,21 @@ const Timeline: React.FC<Props> = ({ | |||||||
|     }, |     }, | ||||||
|     [isFetching] |     [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 latestMarker = useRef<string>() | ||||||
|   const updateMarkers = useCallback( |   const updateMarkers = useCallback( | ||||||
|   | |||||||
| @@ -16,8 +16,8 @@ import { setAccountStorage, useAccountStorage, useGlobalStorage } from '@utils/s | |||||||
| import { StyleConstants } from '@utils/styles/constants' | import { StyleConstants } from '@utils/styles/constants' | ||||||
| import layoutAnimation from '@utils/styles/layoutAnimation' | import layoutAnimation from '@utils/styles/layoutAnimation' | ||||||
| import { useTheme } from '@utils/styles/ThemeManager' | import { useTheme } from '@utils/styles/ThemeManager' | ||||||
|  | import * as Crypto from 'expo-crypto' | ||||||
| import * as Notifications from 'expo-notifications' | import * as Notifications from 'expo-notifications' | ||||||
| import * as Random from 'expo-random' |  | ||||||
| import * as WebBrowser from 'expo-web-browser' | import * as WebBrowser from 'expo-web-browser' | ||||||
| import React, { useEffect, useState } from 'react' | import React, { useEffect, useState } from 'react' | ||||||
| import { useTranslation } from 'react-i18next' | import { useTranslation } from 'react-i18next' | ||||||
| @@ -173,7 +173,7 @@ const TabMePush: React.FC = () => { | |||||||
|                       // Fix a bug for some users of v4.8.0 |                       // Fix a bug for some users of v4.8.0 | ||||||
|                       let authKey = push.key |                       let authKey = push.key | ||||||
|                       if (push.key?.length <= 10) { |                       if (push.key?.length <= 10) { | ||||||
|                         authKey = fromByteArray(Random.getRandomBytes(16)) |                         authKey = fromByteArray(Crypto.getRandomBytes(16)) | ||||||
|                       } |                       } | ||||||
|                       // Turning on |                       // Turning on | ||||||
|                       const randomPath = (Math.random() + 1).toString(36).substring(2) |                       const randomPath = (Math.random() + 1).toString(36).substring(2) | ||||||
|   | |||||||
| @@ -5,13 +5,13 @@ import { LOCALES } from '@i18n/locales' | |||||||
| import { useNavigation } from '@react-navigation/native' | import { useNavigation } from '@react-navigation/native' | ||||||
| import { connectVerify } from '@utils/api/helpers/connect' | import { connectVerify } from '@utils/api/helpers/connect' | ||||||
| import { androidActionSheetStyles } from '@utils/helpers/androidActionSheetStyles' | import { androidActionSheetStyles } from '@utils/helpers/androidActionSheetStyles' | ||||||
|  | import { GLOBAL } from '@utils/storage' | ||||||
| import { useGlobalStorage } from '@utils/storage/actions' | import { useGlobalStorage } from '@utils/storage/actions' | ||||||
| import { useTheme } from '@utils/styles/ThemeManager' | import { useTheme } from '@utils/styles/ThemeManager' | ||||||
| import * as Localization from 'expo-localization' | import * as Localization from 'expo-localization' | ||||||
| import React, { useEffect, useState } from 'react' | import React, { useEffect, useState } from 'react' | ||||||
| import { useTranslation } from 'react-i18next' | import { useTranslation } from 'react-i18next' | ||||||
| import { Linking, Platform } from 'react-native' | import { Linking, Platform } from 'react-native' | ||||||
| import { GLOBAL } from '../../../../App' |  | ||||||
| import { mapFontsizeToName } from '../SettingsFontsize' | import { mapFontsizeToName } from '../SettingsFontsize' | ||||||
|  |  | ||||||
| const SettingsApp: React.FC = () => { | const SettingsApp: React.FC = () => { | ||||||
|   | |||||||
| @@ -1,5 +1,5 @@ | |||||||
|  | import { GLOBAL } from '@utils/storage' | ||||||
| import axios from 'axios' | import axios from 'axios' | ||||||
| import { GLOBAL } from '../../App' |  | ||||||
| import { ctx, handleError, PagedResponse, parseHeaderLinks, userAgent } from './helpers' | import { ctx, handleError, PagedResponse, parseHeaderLinks, userAgent } from './helpers' | ||||||
| import { CONNECT_DOMAIN } from './helpers/connect' | import { CONNECT_DOMAIN } from './helpers/connect' | ||||||
|  |  | ||||||
|   | |||||||
| @@ -1,9 +1,9 @@ | |||||||
| import { mapEnvironment } from '@utils/helpers/checkEnvironment' | import { mapEnvironment } from '@utils/helpers/checkEnvironment' | ||||||
|  | import { GLOBAL } from '@utils/storage' | ||||||
| import { setGlobalStorage } from '@utils/storage/actions' | import { setGlobalStorage } from '@utils/storage/actions' | ||||||
| import axios from 'axios' | import axios from 'axios' | ||||||
| import parse from 'url-parse' | import parse from 'url-parse' | ||||||
| import { userAgent } from '.' | import { userAgent } from '.' | ||||||
| import { GLOBAL } from '../../../App' |  | ||||||
|  |  | ||||||
| const list = [ | const list = [ | ||||||
|   'n61owz4leck', |   'n61owz4leck', | ||||||
|   | |||||||
| @@ -1,10 +1,10 @@ | |||||||
| import * as Sentry from '@sentry/react-native' | import * as Sentry from '@sentry/react-native' | ||||||
|  | import { GLOBAL } from '@utils/storage' | ||||||
| import { setGlobalStorage } from '@utils/storage/actions' | import { setGlobalStorage } from '@utils/storage/actions' | ||||||
| import chalk from 'chalk' | import chalk from 'chalk' | ||||||
| import Constants from 'expo-constants' | import Constants from 'expo-constants' | ||||||
| import { Platform } from 'react-native' | import { Platform } from 'react-native' | ||||||
| import parse from 'url-parse' | import parse from 'url-parse' | ||||||
| import { GLOBAL } from '../../../App' |  | ||||||
|  |  | ||||||
| const userAgent = { | const userAgent = { | ||||||
|   'User-Agent': `tooot/${Constants.expoConfig?.version} ${Platform.OS}/${Platform.Version}` |   'User-Agent': `tooot/${Constants.expoConfig?.version} ${Platform.OS}/${Platform.Version}` | ||||||
|   | |||||||
| @@ -1,7 +1,7 @@ | |||||||
|  | import { GLOBAL } from '@utils/storage' | ||||||
| import { getAccountDetails } from '@utils/storage/actions' | import { getAccountDetails } from '@utils/storage/actions' | ||||||
| import { StorageGlobal } from '@utils/storage/global' | import { StorageGlobal } from '@utils/storage/global' | ||||||
| import axios, { AxiosRequestConfig } from 'axios' | import axios, { AxiosRequestConfig } from 'axios' | ||||||
| import { GLOBAL } from '../../App' |  | ||||||
| import { ctx, handleError, PagedResponse, parseHeaderLinks, userAgent } from './helpers' | import { ctx, handleError, PagedResponse, parseHeaderLinks, userAgent } from './helpers' | ||||||
| import { CONNECT_DOMAIN } from './helpers/connect' | import { CONNECT_DOMAIN } from './helpers/connect' | ||||||
|  |  | ||||||
|   | |||||||
| @@ -4,3 +4,7 @@ import { MMKV } from 'react-native-mmkv' | |||||||
| export const storage: { global: MMKV; account?: MMKV } = { global: new MMKV(), account: undefined } | export const storage: { global: MMKV; account?: MMKV } = { global: new MMKV(), account: undefined } | ||||||
|  |  | ||||||
| export const secureStorage = createSecureStore() | export const secureStorage = createSecureStore() | ||||||
|  |  | ||||||
|  | export const GLOBAL: { connect?: boolean } = { | ||||||
|  |   connect: undefined | ||||||
|  | } | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user