diff --git a/fastlane/Fastfile b/fastlane/Fastfile index 535ea4f0..f66ae8dd 100644 --- a/fastlane/Fastfile +++ b/fastlane/Fastfile @@ -93,7 +93,7 @@ private_lane :build_ios do ) when "production" prepare_appstore_ios - match( type: "appstore", readonly: true ) + match( type: "appstore", readonly: true, include_bitcode: true ) build_ios_app( export_method: "app-store" ) end end diff --git a/fastlane/Gymfile b/fastlane/Gymfile index a8f82852..6f9c2137 100644 --- a/fastlane/Gymfile +++ b/fastlane/Gymfile @@ -1,3 +1,2 @@ scheme "tooot" -workspace "./ios/tooot.xcworkspace" -clean true \ No newline at end of file +workspace "./ios/tooot.xcworkspace" \ No newline at end of file diff --git a/package.json b/package.json index 032e317f..c54941cb 100644 --- a/package.json +++ b/package.json @@ -73,7 +73,7 @@ "react-native-htmlview": "^0.16.0", "react-native-reanimated": "^2.0.0-rc.2", "react-native-safe-area-context": "3.1.9", - "react-native-screens": "~2.17.1", + "react-native-screens": "~2.18.1", "react-native-svg": "12.1.0", "react-native-swipe-list-view": "^3.2.6", "react-native-tab-view": "^2.15.2", diff --git a/src/@types/react-navigation.d.ts b/src/@types/react-navigation.d.ts index ce295b28..1cdd1168 100644 --- a/src/@types/react-navigation.d.ts +++ b/src/@types/react-navigation.d.ts @@ -88,7 +88,7 @@ declare namespace Nav { account: Mastodon.Account initialType: 'following' | 'followers' } - 'Tab-Shared-Search': undefined + 'Tab-Shared-Search': { text: string | undefined } 'Tab-Shared-Toot': { toot: Mastodon.Status rootQueryKey: any diff --git a/src/api/general.ts b/src/api/general.ts index 302f876c..2cd364f7 100644 --- a/src/api/general.ts +++ b/src/api/general.ts @@ -60,7 +60,7 @@ const apiGeneral = async ({ }) .catch(error => { if (sentry) { - Sentry.Native.captureException(error, error) + Sentry.Native.captureException(error, { extra: error }) } if (error.response) { diff --git a/src/screens/Tabs/Local.tsx b/src/screens/Tabs/Local.tsx index 6e9953b7..c7899afc 100644 --- a/src/screens/Tabs/Local.tsx +++ b/src/screens/Tabs/Local.tsx @@ -43,7 +43,10 @@ const TabLocal = React.memo( content='Search' onPress={() => { analytics('search_tap', { page: 'Local' }) - navigation.navigate('Tab-Local', { screen: 'Tab-Shared-Search' }) + navigation.navigate('Tab-Local', { + screen: 'Tab-Shared-Search', + params: { text: undefined } + }) }} /> ) diff --git a/src/screens/Tabs/Public.tsx b/src/screens/Tabs/Public.tsx index 9384935b..08da97df 100644 --- a/src/screens/Tabs/Public.tsx +++ b/src/screens/Tabs/Public.tsx @@ -3,7 +3,9 @@ import { HeaderRight } from '@components/Header' import Timeline from '@components/Timeline' import TimelineDefault from '@components/Timeline/Default' import SegmentedControl from '@react-native-community/segmented-control' +import { BottomTabScreenProps } from '@react-navigation/bottom-tabs' import { useNavigation } from '@react-navigation/native' +import { ScreenTabsParamList } from '@screens/Tabs' import sharedScreens from '@screens/Tabs/Shared/sharedScreens' import { QueryKeyTimeline } from '@utils/queryHooks/timeline' import { getInstanceActive } from '@utils/slices/instancesSlice' @@ -16,13 +18,17 @@ import { TabView } from 'react-native-tab-view' import ViewPagerAdapter from 'react-native-tab-view-viewpager-adapter' import { useSelector } from 'react-redux' +export type TabPublicProps = BottomTabScreenProps< + ScreenTabsParamList, + 'Tab-Public' +> + const Stack = createNativeStackNavigator() const TabPublic = React.memo( - () => { + ({ navigation }: TabPublicProps) => { const { t, i18n } = useTranslation() const { mode } = useTheme() - const navigation = useNavigation() const instanceActive = useSelector(getInstanceActive) const [segment, setSegment] = useState(0) @@ -64,7 +70,10 @@ const TabPublic = React.memo( content='Search' onPress={() => { analytics('search_tap', { page: pages[segment].key }) - navigation.navigate('Tab-Public', { screen: 'Tab-Shared-Search' }) + navigation.navigate('Tab-Public', { + screen: 'Tab-Shared-Search', + params: { text: undefined } + }) }} /> ) @@ -86,7 +95,7 @@ const TabPublic = React.memo( } }) => { const queryKey: QueryKeyTimeline = ['Timeline', { page }] - const renderItem = ({ item }) => ( + const renderItem = ({ item }: any) => ( ) return diff --git a/src/screens/Tabs/Shared/Search.tsx b/src/screens/Tabs/Shared/Search.tsx index 050b6b6e..a17b91b1 100644 --- a/src/screens/Tabs/Shared/Search.tsx +++ b/src/screens/Tabs/Shared/Search.tsx @@ -5,7 +5,7 @@ import TimelineDefault from '@components/Timeline/Default' import { useSearchQuery } from '@utils/queryHooks/search' import { StyleConstants } from '@utils/styles/constants' import { useTheme } from '@utils/styles/ThemeManager' -import React, { useCallback, useEffect, useMemo, useState } from 'react' +import React, { useCallback, useMemo } from 'react' import { Trans, useTranslation } from 'react-i18next' import { KeyboardAvoidingView, @@ -16,31 +16,26 @@ import { View } from 'react-native' import { Circle } from 'react-native-animated-spinkit' +import { SharedSearchProp } from './sharedScreens' -export interface Props { - searchTerm: string | undefined -} - -const TabSharedSearch: React.FC = ({ searchTerm }) => { +const TabSharedSearch: React.FC = ({ + route: { + params: { text } + } +}) => { const { t } = useTranslation('sharedSearch') const { theme } = useTheme() - const { status, data, refetch } = useSearchQuery({ - term: searchTerm, - options: { enabled: false } - }) - const [setctionData, setSectionData] = useState< - { title: string; data: any }[] - >([]) const mapKeyToTranslations = { accounts: t('content.sections.accounts'), hashtags: t('content.sections.hashtags'), statuses: t('content.sections.statuses') } - useEffect( - () => - data && - setSectionData( + const { status, data } = useSearchQuery({ + term: text, + options: { + enabled: text !== undefined, + select: data => Object.keys(data as Mastodon.Results) .map(key => ({ title: key, @@ -58,17 +53,8 @@ const TabSharedSearch: React.FC = ({ searchTerm }) => { return 0 } }) - ), - [data] - ) - - useEffect(() => { - if (searchTerm) { - refetch() - } else { - setSectionData([]) } - }, [searchTerm]) + }) const listEmpty = useMemo(() => { return ( @@ -145,13 +131,13 @@ const TabSharedSearch: React.FC = ({ searchTerm }) => { }} /> ) : null, - [searchTerm] + [text] ) const listItem = useCallback(({ item, section }) => { switch (section.title) { @@ -175,7 +161,7 @@ const TabSharedSearch: React.FC = ({ searchTerm }) => { style={styles.base} renderItem={listItem} stickySectionHeadersEnabled - sections={setctionData} + sections={data || []} ListEmptyComponent={listEmpty} keyboardShouldPersistTaps='always' renderSectionHeader={sectionHeader} diff --git a/src/screens/Tabs/Shared/sharedScreens.tsx b/src/screens/Tabs/Shared/sharedScreens.tsx index 59802026..0de44ca1 100644 --- a/src/screens/Tabs/Shared/sharedScreens.tsx +++ b/src/screens/Tabs/Shared/sharedScreens.tsx @@ -11,15 +11,14 @@ import TabSharedToot from '@screens/Tabs/Shared/Toot' import { StyleConstants } from '@utils/styles/constants' import { useTheme } from '@utils/styles/ThemeManager' import { debounce } from 'lodash' -import React, { useCallback, useState } from 'react' +import React from 'react' import { Trans, useTranslation } from 'react-i18next' -import { Platform, StyleSheet, Text, View } from 'react-native' -import { TextInput } from 'react-native-gesture-handler' +import { Platform, StyleSheet, Text, TextInput, View } from 'react-native' +import { NativeStackNavigationOptions } from 'react-native-screens/lib/typescript/native-stack' import { NativeStackNavigationEventMap, - NativeStackNavigationOptions, NativeStackNavigatorProps -} from 'react-native-screens/lib/typescript/types' +} from 'react-native-screens/lib/typescript/native-stack/types' export type BaseScreens = | Nav.TabLocalStackParamList @@ -60,25 +59,12 @@ const sharedScreens = ( StackNavigationState>, NativeStackNavigationOptions, NativeStackNavigationEventMap, - ({ - initialRouteName, - children, - screenOptions, - ...rest - }: NativeStackNavigatorProps) => JSX.Element + ({ ...rest }: NativeStackNavigatorProps) => JSX.Element > ) => { const { mode, theme } = useTheme() const { t } = useTranslation() - const [searchTerm, setSearchTerm] = useState() - const onChangeText = useCallback( - debounce(text => setSearchTerm(text), 1000, { - trailing: true - }), - [] - ) - return [ ({ headerLeft: () => navigation.goBack()} />, - // https://github.com/react-navigation/react-navigation/issues/6746#issuecomment-583897436 - headerCenter: () => ( - - - } - /> - { + const onChangeText = debounce( + (text: string) => navigation.setParams({ text }), + 1000, + { + trailing: true + } + ) + return ( + + } - ]} - autoFocus - onChangeText={onChangeText} - autoCapitalize='none' - autoCorrect={false} - clearButtonMode='never' - keyboardType='web-search' - onSubmitEditing={({ nativeEvent: { text } }) => - setSearchTerm(text) - } - placeholder={t('sharedSearch:content.header.placeholder')} - placeholderTextColor={theme.secondary} - returnKeyType='go' - /> - - ) + /> + + navigation.setParams({ text }) + } + placeholder={t('sharedSearch:content.header.placeholder')} + placeholderTextColor={theme.secondary} + returnKeyType='go' + /> + + ) + } })} - > - {() => } - , + />, { - displayMessage({ - mode, - type: 'error', - duration: 'long', - message: t('meSettingsPush:error.message'), - description: t('meSettingsPush:error.description'), - onPress: () => { - navigationRef.current?.navigate('Screen-Tabs', { - screen: 'Tab-Me', - params: { - screen: 'Tab-Me-Root' - } - }) - navigationRef.current?.navigate('Screen-Tabs', { - screen: 'Tab-Me', - params: { - screen: 'Tab-Me-Settings' - } - }) - } - }) + }).catch(error => { + if (error.status == 410) { + displayMessage({ + mode, + type: 'error', + duration: 'long', + message: t('meSettingsPush:error.message'), + description: t('meSettingsPush:error.description'), + onPress: () => { + navigationRef.current?.navigate('Screen-Tabs', { + screen: 'Tab-Me', + params: { + screen: 'Tab-Me-Root' + } + }) + navigationRef.current?.navigate('Screen-Tabs', { + screen: 'Tab-Me', + params: { + screen: 'Tab-Me-Settings' + } + }) + } + }) - dispatch(disableAllPushes()) + dispatch(disableAllPushes()) - instances.forEach(instance => { - if (instance.push.global.value) { - apiGeneral<{}>({ - method: 'delete', - domain: instance.url, - url: 'api/v1/push/subscription', - headers: { - Authorization: `Bearer ${instance.token}` - } - }).catch(() => console.log('error!!!')) - } - }) + instances.forEach(instance => { + if (instance.push.global.value) { + apiGeneral<{}>({ + method: 'delete', + domain: instance.url, + url: 'api/v1/push/subscription', + headers: { + Authorization: `Bearer ${instance.token}` + } + }).catch(() => console.log('error!!!')) + } + }) + } }) } diff --git a/src/utils/queryHooks/timeline.ts b/src/utils/queryHooks/timeline.ts index 7b2c3b4c..30dc5d8c 100644 --- a/src/utils/queryHooks/timeline.ts +++ b/src/utils/queryHooks/timeline.ts @@ -194,7 +194,12 @@ const useTimelineQuery = ({ > }) => { const queryKey: QueryKeyTimeline = ['Timeline', { ...queryKeyParams }] - return useInfiniteQuery(queryKey, queryFunction, options) + return useInfiniteQuery(queryKey, queryFunction, { + refetchOnMount: false, + refetchOnReconnect: false, + refetchOnWindowFocus: false, + ...options + }) } // --- Separator --- diff --git a/yarn.lock b/yarn.lock index 4997f463..30a93e65 100644 --- a/yarn.lock +++ b/yarn.lock @@ -8716,10 +8716,10 @@ react-native-safe-area-view@^0.14.9: dependencies: hoist-non-react-statics "^2.3.1" -react-native-screens@~2.17.1: - version "2.17.1" - resolved "https://registry.yarnpkg.com/react-native-screens/-/react-native-screens-2.17.1.tgz#c3c0ac750af48741c5b1635511e6af2a27b74309" - integrity sha512-B4gD5e4csvlVwlhf+RNqjQZ9mHTwe/iL3rXondgZxnKz4oW0QAmtLnLRKOrYVxoaJaF9Fy7jhjo//24/472APQ== +react-native-screens@~2.18.1: + version "2.18.1" + resolved "https://registry.yarnpkg.com/react-native-screens/-/react-native-screens-2.18.1.tgz#47b9991c6f762d00d0ed3233e5283d523e859885" + integrity sha512-r5WZLpmx2hHjC1RgMdPq5YpSU9tEhBpUaZ5M1SUtNIONyiLqQVxabhRCINdebIk4depJiIl7yw2Q85zJyeX6fw== react-native-svg@12.1.0: version "12.1.0"