This commit is contained in:
Zhiyuan Zheng 2021-03-14 00:47:55 +01:00
parent 32a7d23dc9
commit 5fe6cd59f9
No known key found for this signature in database
GPG Key ID: 078A93AB607D85E0
12 changed files with 141 additions and 144 deletions

View File

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

View File

@ -1,3 +1,2 @@
scheme "tooot"
workspace "./ios/tooot.xcworkspace"
clean true
workspace "./ios/tooot.xcworkspace"

View File

@ -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",

View File

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

View File

@ -60,7 +60,7 @@ const apiGeneral = async <T = unknown>({
})
.catch(error => {
if (sentry) {
Sentry.Native.captureException(error, error)
Sentry.Native.captureException(error, { extra: error })
}
if (error.response) {

View File

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

View File

@ -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<Nav.TabPublicStackParamList>()
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) => (
<TimelineDefault item={item} queryKey={queryKey} />
)
return <Timeline queryKey={queryKey} customProps={{ renderItem }} />

View File

@ -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<Props> = ({ searchTerm }) => {
const TabSharedSearch: React.FC<SharedSearchProp> = ({
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<Props> = ({ searchTerm }) => {
return 0
}
})
),
[data]
)
useEffect(() => {
if (searchTerm) {
refetch()
} else {
setSectionData([])
}
}, [searchTerm])
})
const listEmpty = useMemo(() => {
return (
@ -145,13 +131,13 @@ const TabSharedSearch: React.FC<Props> = ({ searchTerm }) => {
<Text style={[styles.sectionFooterText, { color: theme.secondary }]}>
<Trans
i18nKey='sharedSearch:content.notFound'
values={{ searchTerm, type: translation }}
values={{ searchTerm: text, type: translation }}
components={{ bold: <Text style={styles.emptyFontBold} /> }}
/>
</Text>
</View>
) : null,
[searchTerm]
[text]
)
const listItem = useCallback(({ item, section }) => {
switch (section.title) {
@ -175,7 +161,7 @@ const TabSharedSearch: React.FC<Props> = ({ searchTerm }) => {
style={styles.base}
renderItem={listItem}
stickySectionHeadersEnabled
sections={setctionData}
sections={data || []}
ListEmptyComponent={listEmpty}
keyboardShouldPersistTaps='always'
renderSectionHeader={sectionHeader}

View File

@ -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<Record<string, object | undefined>>,
NativeStackNavigationOptions,
NativeStackNavigationEventMap,
({
initialRouteName,
children,
screenOptions,
...rest
}: NativeStackNavigatorProps) => JSX.Element
({ ...rest }: NativeStackNavigatorProps) => JSX.Element
>
) => {
const { mode, theme } = useTheme()
const { t } = useTranslation()
const [searchTerm, setSearchTerm] = useState<string>()
const onChangeText = useCallback(
debounce(text => setSearchTerm(text), 1000, {
trailing: true
}),
[]
)
return [
<Stack.Screen
key='Tab-Shared-Account'
@ -158,54 +144,61 @@ const sharedScreens = (
<Stack.Screen
key='Tab-Shared-Search'
name='Tab-Shared-Search'
component={TabSharedSearch}
options={({ navigation }: SharedSearchProp) => ({
headerLeft: () => <HeaderLeft onPress={() => navigation.goBack()} />,
// https://github.com/react-navigation/react-navigation/issues/6746#issuecomment-583897436
headerCenter: () => (
<View style={styles.searchBar}>
<TextInput
editable={false}
children={
<Text
style={[
styles.textInput,
{
color: theme.primary
}
]}
children={t('sharedSearch:content.header.prefix')}
/>
}
/>
<TextInput
keyboardAppearance={mode}
style={[
styles.textInput,
{
flex: 1,
color: theme.primary,
paddingLeft: StyleConstants.Spacing.XS
headerCenter: () => {
const onChangeText = debounce(
(text: string) => navigation.setParams({ text }),
1000,
{
trailing: true
}
)
return (
<View style={styles.searchBar}>
<TextInput
editable={false}
children={
<Text
style={[
styles.textInput,
{
color: theme.primary
}
]}
children={t('sharedSearch:content.header.prefix')}
/>
}
]}
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'
/>
</View>
)
/>
<TextInput
keyboardAppearance={mode}
style={[
styles.textInput,
{
flex: 1,
color: theme.primary,
paddingLeft: StyleConstants.Spacing.XS
}
]}
autoFocus
onChangeText={onChangeText}
autoCapitalize='none'
autoCorrect={false}
clearButtonMode='never'
keyboardType='web-search'
onSubmitEditing={({ nativeEvent: { text } }) =>
navigation.setParams({ text })
}
placeholder={t('sharedSearch:content.header.placeholder')}
placeholderTextColor={theme.secondary}
returnKeyType='go'
/>
</View>
)
}
})}
>
{() => <TabSharedSearch searchTerm={searchTerm} />}
</Stack.Screen>,
/>,
<Stack.Screen
key='Tab-Shared-Toot'
name='Tab-Shared-Toot'

View File

@ -42,43 +42,45 @@ const pushUseConnect = ({
expoToken
},
sentry: true
}).catch(() => {
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!!!'))
}
})
}
})
}

View File

@ -194,7 +194,12 @@ const useTimelineQuery = <TData = TimelineData>({
>
}) => {
const queryKey: QueryKeyTimeline = ['Timeline', { ...queryKeyParams }]
return useInfiniteQuery(queryKey, queryFunction, options)
return useInfiniteQuery(queryKey, queryFunction, {
refetchOnMount: false,
refetchOnReconnect: false,
refetchOnWindowFocus: false,
...options
})
}
// --- Separator ---

View File

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