1
0
mirror of https://github.com/tooot-app/app synced 2025-06-05 22:19:13 +02:00

Prepare for apk test

This commit is contained in:
Zhiyuan Zheng
2021-01-16 14:16:58 +01:00
parent 74d830a71a
commit 8451d5a565
7 changed files with 32 additions and 20 deletions

View File

@ -1,6 +1,7 @@
import { useNavigation } from '@react-navigation/native'
import { InstanceLocal, localAddInstance } from '@utils/slices/instancesSlice'
import * as AuthSession from 'expo-auth-session'
import Constants from 'expo-constants'
import React, { useEffect } from 'react'
import { useQueryClient } from 'react-query'
import { useDispatch } from 'react-redux'
@ -13,6 +14,18 @@ export interface Props {
const InstanceAuth = React.memo(
({ instanceDomain, appData, goBack }: Props) => {
console.log(Constants.manifest.releaseChannel)
let redirectUri: string
switch (Constants.manifest.releaseChannel) {
case 'production':
case 'staging':
case 'testing':
redirectUri = 'tooot://expo-auth-session'
break
default:
redirectUri = 'exp://127.0.0.1:19000'
break
}
const navigation = useNavigation()
const queryClient = useQueryClient()
const dispatch = useDispatch()
@ -22,7 +35,7 @@ const InstanceAuth = React.memo(
clientId: appData.clientId,
clientSecret: appData.clientSecret,
scopes: ['read', 'write', 'follow', 'push'],
redirectUri: 'exp://127.0.0.1:19000'
redirectUri
},
{
authorizationEndpoint: `https://${instanceDomain}/oauth/authorize`
@ -43,7 +56,7 @@ const InstanceAuth = React.memo(
clientId: appData.clientId,
clientSecret: appData.clientSecret,
scopes: ['read', 'write', 'follow', 'push'],
redirectUri: 'exp://127.0.0.1:19000',
redirectUri,
code: response.params.code,
extraParams: {
grant_type: 'authorization_code'

View File

@ -165,22 +165,16 @@ const Timeline: React.FC<Props> = ({
)
const queryClient = useQueryClient()
const refreshCount = useRef(0)
const refreshControl = useMemo(
() => (
<RefreshControl
{...(Platform.OS === 'android' && { enabled: true })}
refreshing={
refreshCount.current < 2
? Platform.OS === 'ios'
? isFetchingPreviousPage
: isFetchingPreviousPage || isFetching
: isFetching
isFetchingPreviousPage || (isFetching && !isFetchingNextPage)
}
onRefresh={async () => {
if (refreshCount.current < 2) {
await fetchPreviousPage()
refreshCount.current++
onRefresh={() => {
if (hasPreviousPage) {
fetchPreviousPage()
} else {
queryClient.setQueryData<InfiniteData<any> | undefined>(
queryKey,
@ -193,13 +187,12 @@ const Timeline: React.FC<Props> = ({
}
}
)
await refetch()
refreshCount.current = 0
refetch()
}
}}
/>
),
[isFetchingPreviousPage, isFetching]
[hasPreviousPage, isFetchingPreviousPage, isFetching, isFetchingNextPage]
)
const onScrollToIndexFailed = useCallback(error => {
const offset = error.averageItemLength * error.index