Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3496893
D12388.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
2 KB
Referenced Files
None
Subscribers
None
D12388.diff
View Options
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
Details
Attached
Mime Type
text/plain
Expires
Fri, Dec 20, 4:15 PM (16 h, 47 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2678751
Default Alt Text
D12388.diff (2 KB)
Attached To
Mode
D12388: [lib] Set new session if received from fetch_pending_updates
Attached
Detach File
Event Timeline
Log In to Comment