diff --git a/web/account/log-in-form.react.js b/web/account/log-in-form.react.js index b532a2fad..27c4d76c6 100644 --- a/web/account/log-in-form.react.js +++ b/web/account/log-in-form.react.js @@ -1,95 +1,100 @@ // @flow import olm from '@matrix-org/olm'; import { useConnectModal } from '@rainbow-me/rainbowkit'; import * as React from 'react'; import { useDispatch } from 'react-redux'; import { useSigner } from 'wagmi'; import css from './log-in-form.css'; import SIWEButton from './siwe-button.react.js'; import SIWELoginForm from './siwe-login-form.react.js'; import TraditionalLoginForm from './traditional-login-form.react.js'; import OrBreak from '../components/or-break.react.js'; import { setPrimaryIdentityKeys, setNotificationIdentityKeys, } from '../redux/crypto-store-reducer.js'; import { useSelector } from '../redux/redux-utils.js'; function LoginForm(): React.Node { const { openConnectModal } = useConnectModal(); const { data: signer } = useSigner(); const dispatch = useDispatch(); - const primaryIdentityPublicKey = useSelector( - state => state.cryptoStore.primaryIdentityKeys?.ed25519, + const primaryIdentityPublicKeys = useSelector( + state => state.cryptoStore.primaryIdentityKeys, + ); + const notificationIdentityPublicKeys = useSelector( + state => state.cryptoStore.notificationIdentityKeys, ); React.useEffect(() => { (async () => { if ( - primaryIdentityPublicKey !== null && - primaryIdentityPublicKey !== undefined + primaryIdentityPublicKeys !== null && + primaryIdentityPublicKeys !== undefined && + notificationIdentityPublicKeys !== null && + notificationIdentityPublicKeys !== undefined ) { return; } await olm.init(); const identityAccount = new olm.Account(); identityAccount.create(); const { ed25519: identityED25519, curve25519: identityCurve25519 } = JSON.parse(identityAccount.identity_keys()); dispatch({ type: setPrimaryIdentityKeys, payload: { ed25519: identityED25519, curve25519: identityCurve25519 }, }); const notificationAccount = new olm.Account(); notificationAccount.create(); const { ed25519: notificationED25519, curve25519: notificationCurve25519, } = JSON.parse(notificationAccount.identity_keys()); dispatch({ type: setNotificationIdentityKeys, payload: { ed25519: notificationED25519, curve25519: notificationCurve25519, }, }); })(); - }, [dispatch, primaryIdentityPublicKey]); + }, [dispatch, notificationIdentityPublicKeys, primaryIdentityPublicKeys]); const [siweAuthFlowSelected, setSIWEAuthFlowSelected] = React.useState(false); const onSIWEButtonClick = React.useCallback(() => { setSIWEAuthFlowSelected(true); openConnectModal && openConnectModal(); }, [openConnectModal]); const cancelSIWEAuthFlow = React.useCallback(() => { setSIWEAuthFlowSelected(false); }, []); if (siweAuthFlowSelected && signer) { return (
); } return (
); } export default LoginForm;