Page MenuHomePhabricator

D11649.id39185.diff
No OneTemporary

D11649.id39185.diff

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
@@ -5,15 +5,15 @@
import {
keyserverAuthActionTypes,
- logOutActionTypes,
keyserverAuthRawAction,
+ logOutActionTypes,
useLogOut,
} from '../actions/user-actions.js';
import { useCallKeyserverEndpointContext } from '../keyserver-conn/call-keyserver-endpoint-provider.react.js';
import { extractKeyserverIDFromID } from '../keyserver-conn/keyserver-call-utils.js';
import {
- CANCELLED_ERROR,
type CallKeyserverEndpoint,
+ CANCELLED_ERROR,
} from '../keyserver-conn/keyserver-conn-types.js';
import { useKeyserverRecoveryLogIn } from '../keyserver-conn/recovery-utils.js';
import { filterThreadIDsInFilterList } from '../reducers/calendar-filters-reducer.js';
@@ -27,9 +27,9 @@
import { IdentityClientContext } from '../shared/identity-client-context.js';
import type { BaseSocketProps } from '../socket/socket.react.js';
import {
+ type AuthActionSource,
logInActionSources,
type RecoveryActionSource,
- type AuthActionSource,
} from '../types/account-types.js';
import { authoritativeKeyserverID } from '../utils/authoritative-keyserver.js';
import type { CallSingleKeyserverEndpoint } from '../utils/call-single-keyserver-endpoint.js';
@@ -38,8 +38,8 @@
import { useDispatchActionPromise } from '../utils/redux-promise-utils.js';
import { useSelector } from '../utils/redux-utils.js';
import {
- usingCommServicesAccessToken,
relyingOnAuthoritativeKeyserver,
+ usingCommServicesAccessToken,
} from '../utils/services-utils.js';
import sleep from '../utils/sleep.js';
@@ -57,10 +57,33 @@
const dispatchActionPromise = useDispatchActionPromise();
const callLogOut = useLogOut();
+ const { olmAPI } = getConfig();
+
const hasConnectionIssue = useSelector(
state => !!connectionSelector(keyserverID)(state)?.connectionIssue,
);
const cookie = useSelector(cookieSelector(keyserverID));
+ const prevCookieRef = React.useRef(cookie);
+ const notifsSessionReassignmentPromise = React.useRef<?Promise<mixed>>(null);
+
+ React.useEffect(() => {
+ const prevCookie = prevCookieRef.current;
+ prevCookieRef.current = cookie;
+
+ if (cookie === prevCookie || !cookie || !cookie.startsWith('user=')) {
+ return;
+ }
+
+ notifsSessionReassignmentPromise.current = (async () => {
+ await notifsSessionReassignmentPromise.current;
+ await olmAPI.reassignNotificationsSession?.(
+ prevCookie,
+ cookie,
+ keyserverID,
+ );
+ })();
+ }, [cookie, keyserverID, olmAPI]);
+
const dataLoaded = useSelector(state => state.dataLoaded);
const keyserverDeviceToken = useSelector(deviceTokenSelector(keyserverID));
@@ -101,8 +124,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(
(
diff --git a/web/shared-worker/worker/worker-crypto.js b/web/shared-worker/worker/worker-crypto.js
--- a/web/shared-worker/worker/worker-crypto.js
+++ b/web/shared-worker/worker/worker-crypto.js
@@ -365,6 +365,10 @@
if (!value) {
return;
}
+ const valueAtDestination = await localforage.getItem<mixed>(destination);
+ if (valueAtDestination) {
+ return;
+ }
await localforage.setItem(destination, value);
await localforage.removeItem(source);
}

File Metadata

Mime Type
text/plain
Expires
Sat, Nov 30, 2:31 AM (21 h, 31 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2599078
Default Alt Text
D11649.id39185.diff (3 KB)

Event Timeline