2021-01-27 00:35:34 +01:00
|
|
|
import analytics from '@components/analytics'
|
|
|
|
import Icon from '@components/Icon'
|
|
|
|
import { MenuContainer, MenuRow } from '@components/Menu'
|
|
|
|
import { useNavigation } from '@react-navigation/native'
|
|
|
|
import { useSearchQuery } from '@utils/queryHooks/search'
|
|
|
|
import { StyleConstants } from '@utils/styles/constants'
|
|
|
|
import { useTheme } from '@utils/styles/ThemeManager'
|
2021-02-02 22:50:38 +01:00
|
|
|
import * as Updates from 'expo-updates'
|
2021-01-27 00:35:34 +01:00
|
|
|
import * as Linking from 'expo-linking'
|
|
|
|
import * as StoreReview from 'expo-store-review'
|
|
|
|
import * as WebBrowser from 'expo-web-browser'
|
|
|
|
import React from 'react'
|
|
|
|
import { useTranslation } from 'react-i18next'
|
|
|
|
import { useSelector } from 'react-redux'
|
2021-02-20 19:12:44 +01:00
|
|
|
import { getInstanceActive } from '@utils/slices/instancesSlice'
|
2021-01-27 00:35:34 +01:00
|
|
|
|
|
|
|
const SettingsTooot: React.FC = () => {
|
2021-02-20 19:12:44 +01:00
|
|
|
const instanceActive = useSelector(getInstanceActive)
|
2021-01-27 00:35:34 +01:00
|
|
|
const navigation = useNavigation()
|
|
|
|
const { theme } = useTheme()
|
|
|
|
const { t } = useTranslation('meSettings')
|
|
|
|
|
|
|
|
const { isLoading, data } = useSearchQuery({
|
|
|
|
term: '@tooot@xmflsct.com',
|
2021-02-20 19:12:44 +01:00
|
|
|
options: { enabled: instanceActive !== -1 }
|
2021-01-27 00:35:34 +01:00
|
|
|
})
|
|
|
|
|
|
|
|
return (
|
|
|
|
<MenuContainer>
|
|
|
|
<MenuRow
|
|
|
|
title={t('content.support.heading')}
|
|
|
|
content={
|
|
|
|
<Icon
|
|
|
|
name='Heart'
|
|
|
|
size={StyleConstants.Font.Size.M}
|
|
|
|
color={theme.red}
|
|
|
|
/>
|
|
|
|
}
|
|
|
|
iconBack='ChevronRight'
|
|
|
|
onPress={() => {
|
|
|
|
analytics('settings_support_press')
|
2021-03-06 17:55:13 +01:00
|
|
|
Linking.openURL('https://www.buymeacoffee.com/xmflsct')
|
2021-01-27 00:35:34 +01:00
|
|
|
}}
|
|
|
|
/>
|
2021-01-31 03:09:35 +01:00
|
|
|
{__DEV__ ||
|
|
|
|
['production', 'development'].some(channel =>
|
2021-02-02 22:50:38 +01:00
|
|
|
Updates.releaseChannel?.includes(channel)
|
2021-01-31 03:09:35 +01:00
|
|
|
) ? (
|
|
|
|
<MenuRow
|
|
|
|
title={t('content.review.heading')}
|
|
|
|
content={
|
|
|
|
<Icon
|
|
|
|
name='Star'
|
|
|
|
size={StyleConstants.Font.Size.M}
|
|
|
|
color='#FF9500'
|
|
|
|
/>
|
|
|
|
}
|
|
|
|
iconBack='ChevronRight'
|
|
|
|
onPress={() => {
|
|
|
|
analytics('settings_review_press')
|
|
|
|
StoreReview.isAvailableAsync().then(() =>
|
|
|
|
StoreReview.requestReview()
|
|
|
|
)
|
|
|
|
}}
|
|
|
|
/>
|
|
|
|
) : null}
|
2021-01-27 00:35:34 +01:00
|
|
|
<MenuRow
|
2021-01-31 03:09:35 +01:00
|
|
|
title={t('content.contact.heading')}
|
2021-01-27 00:35:34 +01:00
|
|
|
loading={isLoading}
|
|
|
|
content={
|
|
|
|
<Icon
|
|
|
|
name='Mail'
|
|
|
|
size={StyleConstants.Font.Size.M}
|
|
|
|
color={theme.secondary}
|
|
|
|
/>
|
|
|
|
}
|
|
|
|
iconBack='ChevronRight'
|
|
|
|
onPress={() => {
|
|
|
|
const foundAccounts = data?.accounts.filter(
|
2021-02-11 01:33:31 +01:00
|
|
|
account =>
|
|
|
|
account.acct === 'tooot@xmflsct.com' ||
|
|
|
|
account.url === 'https://social.xmflsct.com/@tooot'
|
2021-01-27 00:35:34 +01:00
|
|
|
)
|
|
|
|
if (foundAccounts?.length === 1) {
|
2021-01-30 01:29:15 +01:00
|
|
|
navigation.navigate('Screen-Compose', {
|
2021-01-27 00:35:34 +01:00
|
|
|
type: 'conversation',
|
|
|
|
accts: [foundAccounts[0].acct]
|
|
|
|
})
|
|
|
|
} else {
|
|
|
|
WebBrowser.openBrowserAsync('https://social.xmflsct.com/@tooot')
|
|
|
|
}
|
|
|
|
}}
|
|
|
|
/>
|
|
|
|
</MenuContainer>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
export default SettingsTooot
|