Page MenuHomePhabricator

D9732.id32997.diff
No OneTemporary

D9732.id32997.diff

diff --git a/lib/selectors/account-selectors.js b/lib/selectors/account-selectors.js
--- a/lib/selectors/account-selectors.js
+++ b/lib/selectors/account-selectors.js
@@ -47,12 +47,11 @@
const basePreRequestUserStateForSingleKeyserverSelector: (
keyserverID: string,
- // eslint-disable-next-line no-unused-vars
) => (state: AppState) => PreRequestUserState = keyserverID =>
createSelector(
(state: AppState) => state.currentUserInfo,
cookieSelector,
- sessionIDSelector,
+ sessionIDSelector(keyserverID),
(
currentUserInfo: ?CurrentUserInfo,
cookie: ?string,
diff --git a/lib/selectors/keyserver-selectors.js b/lib/selectors/keyserver-selectors.js
--- a/lib/selectors/keyserver-selectors.js
+++ b/lib/selectors/keyserver-selectors.js
@@ -30,8 +30,13 @@
},
);
-const sessionIDSelector: (state: AppState) => ?string = (state: AppState) =>
- state.keyserverStore.keyserverInfos[ashoatKeyserverID]?.sessionID;
+const baseSessionIDSelector: (
+ keyserverID: string,
+) => (state: AppState) => ?string = keyserverID => (state: AppState) =>
+ state.keyserverStore.keyserverInfos[keyserverID]?.sessionID;
+
+const sessionIDSelector: (keyserverID: string) => (state: AppState) => ?string =
+ _memoize(baseSessionIDSelector);
const baseUpdatesCurrentAsOfSelector: (
keyserverID: string,
diff --git a/lib/selectors/server-calls.js b/lib/selectors/server-calls.js
--- a/lib/selectors/server-calls.js
+++ b/lib/selectors/server-calls.js
@@ -33,7 +33,7 @@
createSelector(
cookieSelector,
urlPrefixSelector(keyserverID),
- sessionIDSelector,
+ sessionIDSelector(keyserverID),
(state: AppState) => state.currentUserInfo,
connectionSelector(keyserverID),
lastCommunicatedPlatformDetailsSelector(keyserverID),
diff --git a/lib/shared/session-utils.js b/lib/shared/session-utils.js
--- a/lib/shared/session-utils.js
+++ b/lib/shared/session-utils.js
@@ -38,7 +38,7 @@
preRequestUserState.cookiesAndSessions[ashoatKeyserverID].cookie !==
cookieSelector(currentReduxState) ||
preRequestUserState.cookiesAndSessions[ashoatKeyserverID].sessionID !==
- sessionIDSelector(currentReduxState))
+ sessionIDSelector(ashoatKeyserverID)(currentReduxState))
);
}
diff --git a/web/selectors/socket-selectors.js b/web/selectors/socket-selectors.js
--- a/web/selectors/socket-selectors.js
+++ b/web/selectors/socket-selectors.js
@@ -47,15 +47,22 @@
keyserverID: string,
) => (state: AppState) => ?() => WebSocket = _memoize(baseOpenSocketSelector);
+const baseSessionIdentificationSelector: (
+ keyserverID: string,
+) => (state: AppState) => SessionIdentification = keyserverID =>
+ createSelector(
+ cookieSelector,
+ sessionIDSelector(keyserverID),
+ (cookie: ?string, sessionID: ?string): SessionIdentification => ({
+ cookie,
+ sessionID,
+ }),
+ );
+
const sessionIdentificationSelector: (
- state: AppState,
-) => SessionIdentification = createSelector(
- cookieSelector,
- sessionIDSelector,
- (cookie: ?string, sessionID: ?string): SessionIdentification => ({
- cookie,
- sessionID,
- }),
+ keyserverID: string,
+) => (state: AppState) => SessionIdentification = _memoize(
+ baseSessionIdentificationSelector,
);
const getSignedIdentityKeysBlobSelector: (
diff --git a/web/socket.react.js b/web/socket.react.js
--- a/web/socket.react.js
+++ b/web/socket.react.js
@@ -45,7 +45,9 @@
const openSocket = useSelector(openSocketSelector(ashoatKeyserverID));
invariant(openSocket, 'openSocket failed to be created');
- const sessionIdentification = useSelector(sessionIdentificationSelector);
+ const sessionIdentification = useSelector(
+ sessionIdentificationSelector(ashoatKeyserverID),
+ );
const preRequestUserState = useSelector(
preRequestUserStateForSingleKeyserverSelector(ashoatKeyserverID),
);

File Metadata

Mime Type
text/plain
Expires
Sat, Nov 9, 9:42 AM (16 h, 14 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2449962
Default Alt Text
D9732.id32997.diff (3 KB)

Event Timeline