Page MenuHomePhabricator

D12388.id41204.diff
No OneTemporary

D12388.id41204.diff

diff --git a/lib/socket/socket.react.js b/lib/socket/socket.react.js
--- a/lib/socket/socket.react.js
+++ b/lib/socket/socket.react.js
@@ -634,22 +634,7 @@
keyserverID: this.props.keyserverID,
},
});
- if (sessionID !== null && sessionID !== undefined) {
- invariant(
- this.initializedWithUserState,
- 'initializedWithUserState should be set when state sync received',
- );
- this.props.dispatch({
- type: setNewSessionActionType,
- payload: {
- sessionChange: { cookieInvalidated: false, sessionID },
- preRequestUserState: this.initializedWithUserState,
- error: null,
- authActionSource: undefined,
- keyserverID: this.props.keyserverID,
- },
- });
- }
+ this.setNewReceivedSession(sessionID);
} else {
const { type, ...actionPayload } = stateSyncMessage.payload;
this.props.dispatch({
@@ -674,6 +659,26 @@
this.markSocketInitialized();
}
+ setNewReceivedSession(sessionID: ?string) {
+ if (sessionID === null || sessionID === undefined) {
+ return;
+ }
+ invariant(
+ this.initializedWithUserState,
+ 'initializedWithUserState should be set when state sync received',
+ );
+ this.props.dispatch({
+ type: setNewSessionActionType,
+ payload: {
+ sessionChange: { cookieInvalidated: false, sessionID },
+ preRequestUserState: this.initializedWithUserState,
+ error: null,
+ authActionSource: undefined,
+ keyserverID: this.props.keyserverID,
+ },
+ });
+ }
+
initializeSocket: (retriesLeft?: number) => Promise<void> = async (
retriesLeft = 1,
) => {
@@ -689,13 +694,9 @@
this.initFailureCount = 0;
this.fetchingPendingUpdates = true;
try {
- const sessionState = this.props.sessionStateFunc();
void this.props.dispatchActionPromise(
fetchPendingUpdatesActionTypes,
- this.props.fetchPendingUpdates({
- ...sessionState,
- keyserverID: this.props.keyserverID,
- }),
+ this.fetchPendingUpdates(),
);
} finally {
this.fetchingPendingUpdates = false;
@@ -733,6 +734,17 @@
}
};
+ async fetchPendingUpdates(): Promise<ClientStateSyncSocketResult> {
+ const sessionState = this.props.sessionStateFunc();
+ const result = await this.props.fetchPendingUpdates({
+ ...sessionState,
+ keyserverID: this.props.keyserverID,
+ });
+ const { sessionID, ...actionPayload } = result;
+ this.setNewReceivedSession(sessionID);
+ return actionPayload;
+ }
+
stopPing() {
if (this.pingTimeoutID) {
clearTimeout(this.pingTimeoutID);

File Metadata

Mime Type
text/plain
Expires
Thu, Dec 19, 10:50 PM (1 h, 5 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2678751
Default Alt Text
D12388.id41204.diff (2 KB)

Event Timeline