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

Use proper environment mapping

This commit is contained in:
Zhiyuan Zheng
2022-01-02 22:28:33 +01:00
parent 22af0bf828
commit 013d55aee2
10 changed files with 99 additions and 40 deletions

View File

@@ -2,6 +2,7 @@ import analytics from '@components/analytics'
import Button from '@components/Button'
import Icon from '@components/Icon'
import { MenuContainer, MenuRow } from '@components/Menu'
import { isDevelopment } from '@utils/checkEnvironment'
import { updateInstancePush } from '@utils/slices/instances/updatePush'
import { updateInstancePushAlert } from '@utils/slices/instances/updatePushAlert'
import { updateInstancePushDecode } from '@utils/slices/instances/updatePushDecode'
@@ -45,11 +46,16 @@ const TabMePush: React.FC = () => {
setPushCanAskAgain(settings.canAskAgain)
}
useEffect(() => {
Notifications.getExpoPushTokenAsync({
experienceId: '@xmflsct/tooot'
})
.then(data => setPushAvailable(!!data))
.catch(() => setPushAvailable(false))
if (isDevelopment) {
setPushAvailable(true)
} else {
Notifications.getExpoPushTokenAsync({
experienceId: '@xmflsct/tooot'
})
.then(data => setPushAvailable(!!data))
.catch(() => setPushAvailable(false))
}
checkPush()
const subscription = AppState.addEventListener('change', checkPush)
return () => {
@@ -106,7 +112,7 @@ const TabMePush: React.FC = () => {
return (
<ScrollView>
{pushAvailable !== false ? (
{pushAvailable === true ? (
<>
{pushEnabled === false ? (
<MenuContainer>

View File

@@ -1,4 +1,4 @@
import * as Updates from 'expo-updates'
import { isDevelopment } from '@utils/checkEnvironment'
import React from 'react'
import { ScrollView } from 'react-native-gesture-handler'
import SettingsAnalytics from './Settings/Analytics'
@@ -13,12 +13,7 @@ const TabMeSettings: React.FC = () => {
<SettingsTooot />
<SettingsAnalytics />
{__DEV__ ||
['development'].some(channel =>
Updates.releaseChannel.includes(channel)
) ? (
<SettingsDev />
) : null}
{isDevelopment ? <SettingsDev /> : null}
</ScrollView>
)
}

View File

@@ -4,7 +4,6 @@ import { MenuContainer, MenuRow } from '@components/Menu'
import { useNavigation } from '@react-navigation/native'
import { StyleConstants } from '@utils/styles/constants'
import { useTheme } from '@utils/styles/ThemeManager'
import * as Updates from 'expo-updates'
import * as Linking from 'expo-linking'
import * as StoreReview from 'expo-store-review'
import * as WebBrowser from 'expo-web-browser'
@@ -12,6 +11,7 @@ import React from 'react'
import { useTranslation } from 'react-i18next'
import { useSelector } from 'react-redux'
import { getInstanceActive } from '@utils/slices/instancesSlice'
import { isCandidate, isDevelopment } from '@utils/checkEnvironment'
const SettingsTooot: React.FC = () => {
const instanceActive = useSelector(getInstanceActive)
@@ -36,10 +36,7 @@ const SettingsTooot: React.FC = () => {
Linking.openURL('https://www.buymeacoffee.com/xmflsct')
}}
/>
{__DEV__ ||
['release', 'development'].some(channel =>
Updates.releaseChannel?.includes(channel)
) ? (
{isDevelopment || isCandidate ? (
<MenuRow
title={t('me.settings.review.heading')}
content={