diff --git a/lib/components/keyserver-connection-handler.js b/lib/components/keyserver-connection-handler.js --- a/lib/components/keyserver-connection-handler.js +++ b/lib/components/keyserver-connection-handler.js @@ -57,10 +57,29 @@ const dispatchActionPromise = useDispatchActionPromise(); const callLogOut = useLogOut(); + const { olmAPI } = getConfig(); + const hasConnectionIssue = useSelector( state => !!connectionSelector(keyserverID)(state)?.connectionIssue, ); const cookie = useSelector(cookieSelector(keyserverID)); + const prevCookie = React.useRef(cookie); + + React.useEffect(() => { + if (cookie === prevCookie.current || !cookie) { + return; + } + + void (async () => { + await olmAPI.reassignNotificationsSession?.( + prevCookie.current, + cookie, + keyserverID, + ); + prevCookie.current = cookie; + })(); + }, [cookie, keyserverID, olmAPI]); + const dataLoaded = useSelector(state => state.dataLoaded); const keyserverDeviceToken = useSelector(deviceTokenSelector(keyserverID)); @@ -101,8 +120,6 @@ invariant(identityContext, 'Identity context should be set'); const { identityClient, getAuthMetadata } = identityContext; - const { olmAPI } = getConfig(); - const preRequestUserInfo = useSelector(state => state.currentUserInfo); const innerPerformAuth = React.useCallback( (