mirror of
https://github.com/tooot-app/app
synced 2025-06-05 22:19:13 +02:00
Use splash screen
Fetch account preferences again after logging in
This commit is contained in:
@ -3,7 +3,7 @@ import { createBottomTabNavigator } from '@react-navigation/bottom-tabs'
|
||||
import { NavigationContainer } from '@react-navigation/native'
|
||||
import { enableScreens } from 'react-native-screens'
|
||||
|
||||
import React from 'react'
|
||||
import React, { useEffect } from 'react'
|
||||
import { StatusBar } from 'react-native'
|
||||
import Toast from 'react-native-toast-message'
|
||||
import { Feather } from '@expo/vector-icons'
|
||||
@ -18,8 +18,12 @@ import { useTheme } from '@utils/styles/ThemeManager'
|
||||
import getCurrentTab from '@utils/getCurrentTab'
|
||||
import { toastConfig } from '@components/toast'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import { useSelector } from 'react-redux'
|
||||
import { getLocalUrl } from './utils/slices/instancesSlice'
|
||||
import { useDispatch, useSelector } from 'react-redux'
|
||||
import {
|
||||
getLocalToken,
|
||||
getLocalUrl,
|
||||
updateLocal
|
||||
} from './utils/slices/instancesSlice'
|
||||
|
||||
enableScreens()
|
||||
const Tab = createBottomTabNavigator<RootStackParamList>()
|
||||
@ -33,7 +37,9 @@ export type RootStackParamList = {
|
||||
}
|
||||
|
||||
export const Index: React.FC = () => {
|
||||
const dispatch = useDispatch()
|
||||
const localInstance = useSelector(getLocalUrl)
|
||||
const localToken = useSelector(getLocalToken)
|
||||
const { i18n } = useTranslation()
|
||||
const { mode, theme } = useTheme()
|
||||
enum barStyle {
|
||||
@ -41,11 +47,18 @@ export const Index: React.FC = () => {
|
||||
dark = 'light-content'
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
if (localInstance && localToken) {
|
||||
dispatch(updateLocal({ url: localInstance, token: localToken }))
|
||||
}
|
||||
}, [])
|
||||
|
||||
return (
|
||||
<>
|
||||
<StatusBar barStyle={barStyle[mode]} />
|
||||
<NavigationContainer theme={themes[mode]} key={i18n.language}>
|
||||
<Tab.Navigator
|
||||
initialRouteName={localInstance ? 'Screen-Local' : 'Screen-Public'}
|
||||
screenOptions={({ route }) => ({
|
||||
tabBarIcon: ({ focused, color, size }) => {
|
||||
let name: any
|
||||
|
@ -1,12 +1,5 @@
|
||||
import React, {
|
||||
createRef,
|
||||
useCallback,
|
||||
useEffect,
|
||||
useRef,
|
||||
useState
|
||||
} from 'react'
|
||||
import React, { useCallback, useEffect, useState } from 'react'
|
||||
import {
|
||||
Animated,
|
||||
Dimensions,
|
||||
Image,
|
||||
StyleSheet,
|
||||
@ -18,7 +11,6 @@ import { useQuery } from 'react-query'
|
||||
import { debounce } from 'lodash'
|
||||
|
||||
import { instanceFetch } from '@utils/fetches/instanceFetch'
|
||||
import client from '@api/client'
|
||||
import * as AuthSession from 'expo-auth-session'
|
||||
import { useDispatch } from 'react-redux'
|
||||
import { updateLocal } from '@utils/slices/instancesSlice'
|
||||
@ -110,7 +102,7 @@ const Login: React.FC = () => {
|
||||
}
|
||||
)
|
||||
dispatch(updateLocal({ url: instanceDomain, token: accessToken }))
|
||||
navigation.navigate('Screen-Local-Root')
|
||||
navigation.navigate('Screen-Local')
|
||||
}
|
||||
})()
|
||||
}, [response])
|
||||
|
@ -163,10 +163,7 @@ const composeInitialState: ComposeState = {
|
||||
},
|
||||
attachments: { sensitive: false, uploads: [] },
|
||||
attachmentUploadProgress: undefined,
|
||||
visibility:
|
||||
getLocalAccountPreferences(store.getState())[
|
||||
'posting:default:visibility'
|
||||
] || 'public',
|
||||
visibility: 'public',
|
||||
visibilityLock: false,
|
||||
replyToStatus: undefined,
|
||||
textInputFocus: {
|
||||
@ -220,7 +217,12 @@ const composeExistingState = ({
|
||||
uploads: incomingStatus.media_attachments
|
||||
}
|
||||
}),
|
||||
visibility: incomingStatus.visibility
|
||||
visibility:
|
||||
incomingStatus.visibility ||
|
||||
getLocalAccountPreferences(store.getState())[
|
||||
'posting:default:visibility'
|
||||
],
|
||||
...(incomingStatus.visibility === 'direct' && { visibilityLock: true })
|
||||
}
|
||||
case 'reply':
|
||||
case 'conversation':
|
||||
@ -337,7 +339,12 @@ const Compose: React.FC<Props> = ({ route: { params } }) => {
|
||||
type: params.type,
|
||||
incomingStatus: params.incomingStatus
|
||||
})
|
||||
: composeInitialState
|
||||
: {
|
||||
...composeInitialState,
|
||||
visibility: getLocalAccountPreferences(store.getState())[
|
||||
'posting:default:visibility'
|
||||
] as ComposeState['visibility']
|
||||
}
|
||||
)
|
||||
const [isSubmitting, setIsSubmitting] = useState(false)
|
||||
|
||||
|
Reference in New Issue
Block a user