From 8451d5a5653a2d29171e38b0ad96c503b5490148 Mon Sep 17 00:00:00 2001 From: Zhiyuan Zheng Date: Sat, 16 Jan 2021 14:16:58 +0100 Subject: [PATCH] Prepare for apk test --- .github/workflows/testing.yml | 2 +- app.config.ts | 2 ++ package.json | 1 + src/components/Instance/Auth.tsx | 17 +++++++++++++++-- src/components/Timelines/Timeline.tsx | 19 ++++++------------- src/screens/Me/Settings.tsx | 9 ++++++--- yarn.lock | 2 +- 7 files changed, 32 insertions(+), 20 deletions(-) diff --git a/.github/workflows/testing.yml b/.github/workflows/testing.yml index 2c34eeb6..8c96acfb 100644 --- a/.github/workflows/testing.yml +++ b/.github/workflows/testing.yml @@ -5,7 +5,7 @@ on: - testing jobs: publish: - runs-on: macos-latest + runs-on: ubuntu-latest steps: - name: -- Step 1 -- Checkout code uses: actions/checkout@v2 diff --git a/app.config.ts b/app.config.ts index 640ceb8f..a4a2a3c6 100644 --- a/app.config.ts +++ b/app.config.ts @@ -17,6 +17,7 @@ export default (): ExpoConfig => ({ }, scheme: 'tooot', ios: { + buildNumber: '0.1.0', bundleIdentifier: 'com.xmflsct.app.tooot', googleServicesFile: './configs/GoogleService-Info.plist', infoPlist: { @@ -24,6 +25,7 @@ export default (): ExpoConfig => ({ } }, android: { + versionCode: 0.1, package: 'com.xmflsct.app.tooot', googleServicesFile: './configs/google-services.json', permissions: ['CAMERA', 'VIBRATE'] diff --git a/package.json b/package.json index c7125373..e1b52115 100644 --- a/package.json +++ b/package.json @@ -25,6 +25,7 @@ "expo-auth-session": "~3.0.0", "expo-av": "~8.7.0", "expo-blur": "~8.2.2", + "expo-constants": "~9.3.3", "expo-crypto": "~8.4.0", "expo-firebase-analytics": "~2.6.0", "expo-firebase-core": "~1.3.0", diff --git a/src/components/Instance/Auth.tsx b/src/components/Instance/Auth.tsx index b323195f..2d5cec10 100644 --- a/src/components/Instance/Auth.tsx +++ b/src/components/Instance/Auth.tsx @@ -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' diff --git a/src/components/Timelines/Timeline.tsx b/src/components/Timelines/Timeline.tsx index 77fa711f..84a1c234 100644 --- a/src/components/Timelines/Timeline.tsx +++ b/src/components/Timelines/Timeline.tsx @@ -165,22 +165,16 @@ const Timeline: React.FC = ({ ) const queryClient = useQueryClient() - const refreshCount = useRef(0) const refreshControl = useMemo( () => ( { - if (refreshCount.current < 2) { - await fetchPreviousPage() - refreshCount.current++ + onRefresh={() => { + if (hasPreviousPage) { + fetchPreviousPage() } else { queryClient.setQueryData | undefined>( queryKey, @@ -193,13 +187,12 @@ const Timeline: React.FC = ({ } } ) - await refetch() - refreshCount.current = 0 + refetch() } }} /> ), - [isFetchingPreviousPage, isFetching] + [hasPreviousPage, isFetchingPreviousPage, isFetching, isFetchingNextPage] ) const onScrollToIndexFailed = useCallback(error => { const offset = error.averageItemLength * error.index diff --git a/src/screens/Me/Settings.tsx b/src/screens/Me/Settings.tsx index e05cb521..fc69f5c6 100644 --- a/src/screens/Me/Settings.tsx +++ b/src/screens/Me/Settings.tsx @@ -1,14 +1,14 @@ import Button from '@components/Button' +import haptics from '@components/haptics' import { MenuContainer, MenuRow } from '@components/Menu' import { useActionSheet } from '@expo/react-native-action-sheet' import { useNavigation } from '@react-navigation/native' -import haptics from '@root/components/haptics' import { persistor } from '@root/store' import { getLocalActiveIndex, getLocalInstances, getRemoteUrl -} from '@root/utils/slices/instancesSlice' +} from '@utils/slices/instancesSlice' import { changeAnalytics, changeBrowser, @@ -21,6 +21,7 @@ import { } from '@utils/slices/settingsSlice' import { StyleConstants } from '@utils/styles/constants' import { useTheme } from '@utils/styles/ThemeManager' +import Constants from 'expo-constants' import prettyBytes from 'pretty-bytes' import React, { useEffect, useState } from 'react' import { useTranslation } from 'react-i18next' @@ -232,7 +233,9 @@ const ScreenMeSettings: React.FC = () => { - {__DEV__ ? : null} + {__DEV__ || Constants.manifest.releaseChannel === 'testing' ? ( + + ) : null} ) } diff --git a/yarn.lock b/yarn.lock index cfc35d0e..209eb7ac 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2152,7 +2152,7 @@ resolved "https://registry.yarnpkg.com/@types/lodash/-/lodash-4.14.166.tgz#07e7f2699a149219dbc3c35574f126ec8737688f" integrity sha512-A3YT/c1oTlyvvW/GQqG86EyqWNrT/tisOIh2mW3YCgcx71TNjiTZA3zYZWA5BCmtsOTXjhliy4c4yEkErw6njA== -"@types/node@*", "@types/node@^14.14.7": +"@types/node@*": version "14.14.16" resolved "https://registry.yarnpkg.com/@types/node/-/node-14.14.16.tgz#3cc351f8d48101deadfed4c9e4f116048d437b4b" integrity sha512-naXYePhweTi+BMv11TgioE2/FXU4fSl29HAH1ffxVciNsH3rYXjNP2yM8wqmSm7jS20gM8TIklKiTen+1iVncw==