From 8e75f76600acdd0db489a60d938f853f58dbc153 Mon Sep 17 00:00:00 2001 From: Kacper Michalik Date: Wed, 29 Nov 2023 12:29:37 +0100 Subject: [PATCH] fix: mobile channel list screen --- .../ConnectionProcess.screen.tsx | 16 ++++++++++++---- .../src/sagas/appConnection/connection.slice.ts | 1 + 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/packages/mobile/src/screens/ConnectionProcess/ConnectionProcess.screen.tsx b/packages/mobile/src/screens/ConnectionProcess/ConnectionProcess.screen.tsx index 4ef7011059..f207eebf3d 100644 --- a/packages/mobile/src/screens/ConnectionProcess/ConnectionProcess.screen.tsx +++ b/packages/mobile/src/screens/ConnectionProcess/ConnectionProcess.screen.tsx @@ -1,5 +1,5 @@ import React, { FC, useCallback, useEffect } from 'react' -import { communities, connection, ErrorCodes, errors, publicChannels, users } from '@quiet/state-manager' +import { communities, connection, ErrorCodes, errors, network, publicChannels, users } from '@quiet/state-manager' import { useDispatch, useSelector } from 'react-redux' import ConnectionProcessComponent from '../../components/ConnectionProcess/ConnectionProcess.component' import { Linking } from 'react-native' @@ -21,6 +21,12 @@ export const ConnectionProcessScreen: FC = () => { const certificatesMapping = useSelector(users.selectors.certificatesMapping) const channels = useSelector(publicChannels.selectors.publicChannels) + const communityId = useSelector(communities.selectors.currentCommunityId) + const initializedCommunities = useSelector(network.selectors.initializedCommunities) + const isCommunityInitialized = Boolean(initializedCommunities[communityId]) + + const currentChannelDisplayableMessages = useSelector(publicChannels.selectors.currentChannelMessagesMergedBySender) + const openUrl = useCallback((url: string) => { void Linking.openURL(url) }, []) @@ -36,17 +42,19 @@ export const ConnectionProcessScreen: FC = () => { }, [error, dispatch]) useEffect(() => { + const areMessagesLoaded = Object.values(currentChannelDisplayableMessages).length > 0 const areChannelsLoaded = channels.length > 0 const areCertificatesLoaded = Object.values(certificatesMapping).length > 0 const isAllDataLoaded = areChannelsLoaded && areCertificatesLoaded - console.log({ areChannelsLoaded, areCertificatesLoaded }) - if (isOwner ? connectionProcessSelector.number == 85 : isAllDataLoaded && messageNotNull.length !== 0) { + + if (isCommunityInitialized && areMessagesLoaded && isAllDataLoaded) { dispatch( navigationActions.replaceScreen({ screen: ScreenNames.ChannelListScreen, }) ) } - }, [connectionProcessSelector, messageNotNull, certificatesMapping, channels]) + }, [isCommunityInitialized, currentChannelDisplayableMessages, certificatesMapping, channels]) + return } diff --git a/packages/state-manager/src/sagas/appConnection/connection.slice.ts b/packages/state-manager/src/sagas/appConnection/connection.slice.ts index a61b66fa49..a49ccc5a11 100644 --- a/packages/state-manager/src/sagas/appConnection/connection.slice.ts +++ b/packages/state-manager/src/sagas/appConnection/connection.slice.ts @@ -63,6 +63,7 @@ export const connectionSlice = createSlice({ state.connectionProcess = { number: 30, text: ConnectionProcessInfo.BACKEND_MODULES } break case ConnectionProcessInfo.CONNECTING_TO_COMMUNITY: + if (state.connectionProcess.number == 50) break state.connectionProcess = { number: 50, text: ConnectionProcessInfo.CONNECTING_TO_COMMUNITY } break case ConnectionProcessInfo.CHANNELS_REPLICATED || ConnectionProcessInfo.CERTIFICATES_REPLICATED: