diff --git a/package.json b/package.json index 8008888b..5b3c0a91 100644 --- a/package.json +++ b/package.json @@ -3,7 +3,7 @@ "versions": { "native": "220102", "major": 3, - "minor": 1, + "minor": 2, "patch": 0, "expo": "44.0.0" }, diff --git a/src/Screens.tsx b/src/Screens.tsx index 5ea6f42a..639c0ee8 100644 --- a/src/Screens.tsx +++ b/src/Screens.tsx @@ -9,6 +9,7 @@ import ScreenAnnouncements from '@screens/Announcements' import ScreenCompose from '@screens/Compose' import ScreenImagesViewer from '@screens/ImagesViewer' import ScreenTabs from '@screens/Tabs' +import initQuery from '@utils/initQuery' import { RootStackParamList } from '@utils/navigation/navigators' import pushUseConnect from '@utils/push/useConnect' import pushUseReceive from '@utils/push/useReceive' @@ -17,11 +18,7 @@ import { updatePreviousTab } from '@utils/slices/contextsSlice' import { updateAccountPreferences } from '@utils/slices/instances/updateAccountPreferences' import { updateConfiguration } from '@utils/slices/instances/updateConfiguration' import { updateFilters } from '@utils/slices/instances/updateFilters' -import { - getInstanceActive, - getInstances, - updateInstanceActive -} from '@utils/slices/instancesSlice' +import { getInstanceActive, getInstances } from '@utils/slices/instancesSlice' import { useTheme } from '@utils/styles/ThemeManager' import { themes } from '@utils/styles/themes' import * as Analytics from 'expo-firebase-analytics' @@ -76,9 +73,9 @@ const Screens: React.FC = ({ localCorrupt }) => { (prev, next) => prev.length === next.length ) const queryClient = useQueryClient() - pushUseConnect({ mode, t, instances, dispatch }) - pushUseReceive({ queryClient, instances }) - pushUseRespond({ queryClient, instances, dispatch }) + pushUseConnect({ t, instances }) + pushUseReceive({ instances }) + pushUseRespond({ instances }) // Prevent screenshot alert useEffect(() => { @@ -165,8 +162,10 @@ const Screens: React.FC = ({ localCorrupt }) => { instance => paths[0] === `@${instance.account.acct}@${instance.uri}` ) if (instanceIndex !== -1 && instanceActive !== instanceIndex) { - dispatch(updateInstanceActive(instances[instanceIndex])) - queryClient.clear() + initQuery({ + instance: instances[instanceIndex], + prefetch: { enabled: true } + }) } } } diff --git a/src/components/Timeline.tsx b/src/components/Timeline.tsx index 3b168aa6..d1993a75 100644 --- a/src/components/Timeline.tsx +++ b/src/components/Timeline.tsx @@ -48,9 +48,6 @@ const Timeline: React.FC = ({ lookback, customProps }) => { - // Switching account update timeline - useSelector(getInstanceActive) - const { theme } = useTheme() const { @@ -152,6 +149,13 @@ const Timeline: React.FC = ({ ]) useScrollToTop(flRef) + useSelector(getInstanceActive, (prev, next) => { + if (prev !== next) { + flRef.current?.scrollToOffset({ offset: 0, animated: false }) + } + return prev === next + }) + return ( <> = ({ disableRefresh={disableRefresh} /> image.id === id) const [currentIndex, setCurrentIndex] = useState(initialIndex) const messageRef = useRef(null) diff --git a/src/screens/Tabs/Me/Switch.tsx b/src/screens/Tabs/Me/Switch.tsx index 151b155a..1f57816a 100644 --- a/src/screens/Tabs/Me/Switch.tsx +++ b/src/screens/Tabs/Me/Switch.tsx @@ -3,11 +3,11 @@ import Button from '@components/Button' import haptics from '@components/haptics' import ComponentInstance from '@components/Instance' import { useNavigation } from '@react-navigation/native' +import initQuery from '@utils/initQuery' import { getInstanceActive, getInstances, - Instance, - updateInstanceActive + Instance } from '@utils/slices/instancesSlice' import { StyleConstants } from '@utils/styles/constants' import { useTheme } from '@utils/styles/ThemeManager' @@ -21,8 +21,7 @@ import { View } from 'react-native' import { ScrollView } from 'react-native-gesture-handler' -import { useQueryClient } from 'react-query' -import { useDispatch, useSelector } from 'react-redux' +import { useSelector } from 'react-redux' interface Props { instance: Instance @@ -30,9 +29,7 @@ interface Props { } const AccountButton: React.FC = ({ instance, selected = false }) => { - const queryClient = useQueryClient() const navigation = useNavigation() - const dispatch = useDispatch() return (