Skip to content

Commit

Permalink
fix: mobile channel list screen
Browse files Browse the repository at this point in the history
  • Loading branch information
Kacper-RF committed Nov 29, 2023
1 parent 906f564 commit 8e75f76
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -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'
Expand All @@ -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)
}, [])
Expand All @@ -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 <ConnectionProcessComponent openUrl={openUrl} connectionProcess={connectionProcessSelector} />
}
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 8e75f76

Please sign in to comment.