Skip to content

Commit

Permalink
fix: move app_ready event
Browse files Browse the repository at this point in the history
  • Loading branch information
siepra committed Apr 23, 2024
1 parent de6eb32 commit de8fb25
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 4 deletions.
1 change: 0 additions & 1 deletion packages/mobile/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ function App(): JSX.Element {

useEffect(() => {
console.log('LAUNCHED APPLICATION: ', (Math.random() + 1).toString(36).substring(7))
NativeModules.CommunicationModule.handleIncomingEvents(APP_READY_CHANNEL, null, null)
}, [])

return (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { io } from 'socket.io-client'
import { select, put, call, cancel, fork, takeEvery, FixedTask } from 'typed-redux-saga'
import { select, put, call, cancel, fork, takeEvery, delay, FixedTask } from 'typed-redux-saga'
import { PayloadAction } from '@reduxjs/toolkit'
import { socket as stateManager, Socket } from '@quiet/state-manager'
import { encodeSecret } from '@quiet/common'
Expand All @@ -13,6 +13,16 @@ export function* startConnectionSaga(
const isAlreadyConnected = yield* select(initSelectors.isWebsocketConnected)
if (isAlreadyConnected) return

while (true) {
const isCryptoEngineInitialized = yield* select(initSelectors.isCryptoEngineInitialized)
console.log('WEBSOCKET', 'Waiting for crypto engine to initialize')
if (!isCryptoEngineInitialized) {
yield* delay(500)
} else {
break
}
}

const { dataPort, socketIOSecret } = action.payload

console.log('WEBSOCKET', 'Entered start connection saga', dataPort)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
import { put, take, select } from 'typed-redux-saga'
import { NativeModules } from 'react-native'
import { call, put, take, select } from 'typed-redux-saga'
import { initSelectors } from '../../init/init.selectors'
import { navigationSelectors } from '../navigation.selectors'
import { navigationActions } from '../navigation.slice'
import { ScreenNames } from '../../../const/ScreenNames.enum'
import { identity } from '@quiet/state-manager'
import { APP_READY_CHANNEL, identity } from '@quiet/state-manager'
import { initActions } from '../../init/init.slice'

export function* redirectionSaga(): Generator {
// Let the native modules know to init web socket connection
yield* call(NativeModules.CommunicationModule.handleIncomingEvents, APP_READY_CHANNEL, null, null)

// Do not redirect if user opened the app from url (quiet://)
const deepLinking = yield* select(initSelectors.deepLinking)
if (deepLinking) {
Expand Down

0 comments on commit de8fb25

Please sign in to comment.