Page MenuHomePhabricator

D10309.diff
No OneTemporary

D10309.diff

diff --git a/lib/selectors/socket-selectors.js b/lib/selectors/socket-selectors.js
--- a/lib/selectors/socket-selectors.js
+++ b/lib/selectors/socket-selectors.js
@@ -6,8 +6,11 @@
import {
updatesCurrentAsOfSelector,
currentAsOfSelector,
+ urlPrefixSelector,
+ cookieSelector,
} from './keyserver-selectors.js';
import { currentCalendarQuery } from './nav-selectors.js';
+import { createOpenSocketFunction } from '../shared/socket-utils.js';
import type { BoundStateSyncSpec } from '../shared/state-sync/state-sync-spec.js';
import { stateSyncSpecs } from '../shared/state-sync/state-sync-specs.js';
import threadWatcher from '../shared/thread-watcher.js';
@@ -26,6 +29,29 @@
import { minimumOneTimeKeysRequired } from '../utils/crypto-utils.js';
import { values } from '../utils/objects.js';
+const baseOpenSocketSelector: (
+ keyserverID: string,
+) => (state: AppState) => ?() => WebSocket = keyserverID =>
+ createSelector(
+ urlPrefixSelector(keyserverID),
+ // We don't actually use the cookie in the socket open function,
+ // but we do use it in the initial message, and when the cookie changes
+ // the socket needs to be reopened. By including the cookie here,
+ // whenever the cookie changes this function will change,
+ // which tells the Socket component to restart the connection.
+ cookieSelector(keyserverID),
+ (urlPrefix: ?string) => {
+ if (!urlPrefix) {
+ return null;
+ }
+ return createOpenSocketFunction(urlPrefix);
+ },
+ );
+
+const openSocketSelector: (
+ keyserverID: string,
+) => (state: AppState) => ?() => WebSocket = _memoize(baseOpenSocketSelector);
+
const queuedReports: (
state: AppState,
) => $ReadOnlyArray<ClientReportCreationRequest> = createSelector(
@@ -223,4 +249,9 @@
baseSessionStateFuncSelector,
);
-export { queuedReports, getClientResponsesSelector, sessionStateFuncSelector };
+export {
+ openSocketSelector,
+ queuedReports,
+ getClientResponsesSelector,
+ sessionStateFuncSelector,
+};
diff --git a/native/selectors/socket-selectors.js b/native/selectors/socket-selectors.js
--- a/native/selectors/socket-selectors.js
+++ b/native/selectors/socket-selectors.js
@@ -3,15 +3,11 @@
import _memoize from 'lodash/memoize.js';
import { createSelector } from 'reselect';
-import {
- cookieSelector,
- urlPrefixSelector,
-} from 'lib/selectors/keyserver-selectors.js';
+import { cookieSelector } from 'lib/selectors/keyserver-selectors.js';
import {
getClientResponsesSelector,
sessionStateFuncSelector,
} from 'lib/selectors/socket-selectors.js';
-import { createOpenSocketFunction } from 'lib/shared/socket-utils.js';
import type { SignedIdentityKeysBlob } from 'lib/types/crypto-types.js';
import type {
ClientServerRequest,
@@ -28,29 +24,6 @@
import type { AppState } from '../redux/state-types.js';
import type { NavPlusRedux } from '../types/selector-types.js';
-const baseOpenSocketSelector: (
- keyserverID: string,
-) => (state: AppState) => ?() => WebSocket = keyserverID =>
- createSelector(
- urlPrefixSelector(keyserverID),
- // We don't actually use the cookie in the socket open function,
- // but we do use it in the initial message, and when the cookie changes
- // the socket needs to be reopened. By including the cookie here,
- // whenever the cookie changes this function will change,
- // which tells the Socket component to restart the connection.
- cookieSelector(keyserverID),
- (urlPrefix: ?string) => {
- if (!urlPrefix) {
- return null;
- }
- return createOpenSocketFunction(urlPrefix);
- },
- );
-
-const openSocketSelector: (
- keyserverID: string,
-) => (state: AppState) => ?() => WebSocket = _memoize(baseOpenSocketSelector);
-
const baseSessionIdentificationSelector: (
keyserverID: string,
) => (state: AppState) => SessionIdentification = keyserverID =>
@@ -144,7 +117,6 @@
);
export {
- openSocketSelector,
sessionIdentificationSelector,
nativeGetClientResponsesSelector,
nativeSessionStateFuncSelector,
diff --git a/native/socket.react.js b/native/socket.react.js
--- a/native/socket.react.js
+++ b/native/socket.react.js
@@ -11,6 +11,7 @@
connectionSelector,
lastCommunicatedPlatformDetailsSelector,
} from 'lib/selectors/keyserver-selectors.js';
+import { openSocketSelector } from 'lib/selectors/socket-selectors.js';
import { isLoggedIn } from 'lib/selectors/user-selectors.js';
import { accountHasPassword } from 'lib/shared/account-utils.js';
import { useInitialNotificationsEncryptedMessage } from 'lib/shared/crypto-utils.js';
@@ -30,7 +31,6 @@
import { useSelector } from './redux/redux-utils.js';
import { noDataAfterPolicyAcknowledgmentSelector } from './selectors/account-selectors.js';
import {
- openSocketSelector,
sessionIdentificationSelector,
nativeGetClientResponsesSelector,
nativeSessionStateFuncSelector,
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
@@ -5,14 +5,12 @@
import {
sessionIDSelector,
- urlPrefixSelector,
cookieSelector,
} from 'lib/selectors/keyserver-selectors.js';
import {
getClientResponsesSelector,
sessionStateFuncSelector,
} from 'lib/selectors/socket-selectors.js';
-import { createOpenSocketFunction } from 'lib/shared/socket-utils.js';
import type { SignedIdentityKeysBlob } from 'lib/types/crypto-types.js';
import type {
ClientServerRequest,
@@ -26,20 +24,6 @@
import type { AppState } from '../redux/redux-setup.js';
-const baseOpenSocketSelector: (
- keyserverID: string,
-) => (state: AppState) => ?() => WebSocket = keyserverID =>
- createSelector(urlPrefixSelector(keyserverID), (urlPrefix: ?string) => {
- if (!urlPrefix) {
- return null;
- }
- return createOpenSocketFunction(urlPrefix);
- });
-
-const openSocketSelector: (
- keyserverID: string,
-) => (state: AppState) => ?() => WebSocket = _memoize(baseOpenSocketSelector);
-
const baseSessionIdentificationSelector: (
keyserverID: string,
) => (state: AppState) => SessionIdentification = keyserverID =>
@@ -120,7 +104,6 @@
);
export {
- openSocketSelector,
sessionIdentificationSelector,
webGetClientResponsesSelector,
webSessionStateFuncSelector,
diff --git a/web/socket.react.js b/web/socket.react.js
--- a/web/socket.react.js
+++ b/web/socket.react.js
@@ -10,6 +10,7 @@
connectionSelector,
lastCommunicatedPlatformDetailsSelector,
} from 'lib/selectors/keyserver-selectors.js';
+import { openSocketSelector } from 'lib/selectors/socket-selectors.js';
import { useInitialNotificationsEncryptedMessage } from 'lib/shared/crypto-utils.js';
import Socket, { type BaseSocketProps } from 'lib/socket/socket.react.js';
import type { OLMIdentityKeys } from 'lib/types/crypto-types.js';
@@ -28,7 +29,6 @@
webCalendarQuery,
} from './selectors/nav-selectors.js';
import {
- openSocketSelector,
sessionIdentificationSelector,
webGetClientResponsesSelector,
webSessionStateFuncSelector,

File Metadata

Mime Type
text/plain
Expires
Mon, Dec 2, 7:20 PM (21 h, 20 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2608652
Default Alt Text
D10309.diff (6 KB)

Event Timeline