diff --git a/lib/tunnelbroker/peer-to-peer-message-handler.js b/lib/tunnelbroker/peer-to-peer-message-handler.js --- a/lib/tunnelbroker/peer-to-peer-message-handler.js +++ b/lib/tunnelbroker/peer-to-peer-message-handler.js @@ -9,6 +9,7 @@ } from './use-peer-to-peer-message-handler.js'; import { useLoggedInUserInfo } from '../hooks/account-hooks.js'; import { useActionsQueue } from '../hooks/actions-queue.js'; +import { usePersistedStateLoaded } from '../selectors/app-state-selectors.js'; import type { InboundP2PMessage } from '../types/sqlite-types.js'; import type { MessageReceiveConfirmation } from '../types/tunnelbroker/message-receive-confirmation-types.js'; import { @@ -34,6 +35,7 @@ const { addListener, removeListener } = useTunnelbroker(); const peerToPeerMessageHandler = usePeerToPeerMessageHandler(); const handleOlmMessageToDevice = useHandleOlmMessageToDevice(); + const persistedStateLoaded = usePersistedStateLoaded(); const processItem = React.useCallback( async ( @@ -180,12 +182,16 @@ const processingInputMessagesStarted = React.useRef(false); React.useEffect(() => { - if (!viewerID || processingInputMessagesStarted.current) { + if ( + !viewerID || + processingInputMessagesStarted.current || + !persistedStateLoaded + ) { return; } processingInputMessagesStarted.current = true; void processPersistedInboundMessages(); - }, [processPersistedInboundMessages, viewerID]); + }, [processPersistedInboundMessages, viewerID, persistedStateLoaded]); } export { PeerToPeerMessageHandler }; diff --git a/native/account/logged-out-modal.react.js b/native/account/logged-out-modal.react.js --- a/native/account/logged-out-modal.react.js +++ b/native/account/logged-out-modal.react.js @@ -23,6 +23,7 @@ import { useIsLoggedInToAuthoritativeKeyserver } from 'lib/hooks/account-hooks.js'; import { setActiveSessionRecoveryActionType } from 'lib/keyserver-conn/keyserver-conn-types.js'; +import { usePersistedStateLoaded } from 'lib/selectors/app-state-selectors.js'; import { isLoggedIn } from 'lib/selectors/user-selectors.js'; import { recoveryFromReduxActionSources } from 'lib/types/account-types.js'; import { useDispatch } from 'lib/utils/redux-utils.js'; @@ -47,7 +48,6 @@ QRCodeSignInNavigatorRouteName, } from '../navigation/route-names.js'; import { useSelector } from '../redux/redux-utils.js'; -import { usePersistedStateLoaded } from '../selectors/app-state-selectors.js'; import { derivedDimensionsInfoSelector } from '../selectors/dimensions-selectors.js'; import { splashStyleSelector } from '../splash.js'; import { useStyles } from '../themes/colors.js';