Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3361946
D11217.id37750.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
4 KB
Referenced Files
None
Subscribers
None
D11217.id37750.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
@@ -87,7 +87,6 @@
};
type Props = {
...BaseSocketProps,
- // Redux state
+active: boolean,
+openSocket: () => CommTransportLayer,
+getClientResponses: (
@@ -105,11 +104,9 @@
+lastCommunicatedPlatformDetails: ?PlatformDetails,
+decompressSocketMessage: CompressedData => string,
+activeSessionRecovery: null | RecoveryActionSource,
- // Redux dispatch functions
+dispatch: Dispatch,
+dispatchActionPromise: DispatchActionPromise,
- // async functions that hit server APIs
- +socketCrashLoopRecovery?: () => mixed,
+ +showSocketCrashLoopAlert?: () => mixed,
};
type State = {
+inflightRequests: ?InflightRequests,
@@ -663,12 +660,17 @@
} else {
this.failuresAfterPolicyAcknowledgment = 0;
}
- if (
- this.failuresAfterPolicyAcknowledgment >= 2 &&
- this.props.socketCrashLoopRecovery
- ) {
+ if (this.failuresAfterPolicyAcknowledgment >= 2) {
this.failuresAfterPolicyAcknowledgment = 0;
- this.props.socketCrashLoopRecovery();
+ this.props.showSocketCrashLoopAlert?.();
+ this.props.dispatch({
+ type: setActiveSessionRecoveryActionType,
+ payload: {
+ activeSessionRecovery:
+ recoveryActionSources.refetchUserDataAfterAcknowledgment,
+ keyserverID: this.props.keyserverID,
+ },
+ });
return;
}
diff --git a/native/socket.react.js b/native/socket.react.js
--- a/native/socket.react.js
+++ b/native/socket.react.js
@@ -3,7 +3,6 @@
import invariant from 'invariant';
import * as React from 'react';
-import { setActiveSessionRecoveryActionType } from 'lib/keyserver-conn/keyserver-conn-types.js';
import { canResolveKeyserverSessionInvalidation } from 'lib/keyserver-conn/recovery-utils.js';
import { preRequestUserStateForSingleKeyserverSelector } from 'lib/selectors/account-selectors.js';
import {
@@ -16,7 +15,6 @@
import { accountHasPassword } from 'lib/shared/account-utils.js';
import { useInitialNotificationsEncryptedMessage } from 'lib/shared/crypto-utils.js';
import Socket, { type BaseSocketProps } from 'lib/socket/socket.react.js';
-import { recoveryActionSources } from 'lib/types/account-types.js';
import { useDispatchActionPromise } from 'lib/utils/redux-promise-utils.js';
import { useDispatch } from 'lib/utils/redux-utils.js';
import { usingCommServicesAccessToken } from 'lib/utils/services-utils.js';
@@ -105,27 +103,22 @@
const dispatchActionPromise = useDispatchActionPromise();
const hasPassword = accountHasPassword(currentUserInfo);
- const socketCrashLoopRecovery = React.useCallback(() => {
+ const showSocketCrashLoopAlert = React.useCallback(() => {
if (
- !canResolveKeyserverSessionInvalidation() ||
- (!hasPassword && !usingCommServicesAccessToken)
+ canResolveKeyserverSessionInvalidation() &&
+ (hasPassword || usingCommServicesAccessToken)
) {
- Alert.alert(
- 'Log in needed',
- 'After acknowledging the policies, we need you to log in to your ' +
- 'account again',
- [{ text: 'OK' }],
- );
+ // In this case, we expect that the socket crash loop recovery
+ // will be invisible to the user, so we don't show an alert
+ return;
}
- dispatch({
- type: setActiveSessionRecoveryActionType,
- payload: {
- activeSessionRecovery:
- recoveryActionSources.refetchUserDataAfterAcknowledgment,
- keyserverID,
- },
- });
- }, [hasPassword, dispatch, keyserverID]);
+ Alert.alert(
+ 'Log in needed',
+ 'After acknowledging the policies, we need you to log in to your ' +
+ 'account again',
+ [{ text: 'OK' }],
+ );
+ }, [hasPassword]);
const activeSessionRecovery = useSelector(
state =>
@@ -150,7 +143,7 @@
dispatch={dispatch}
dispatchActionPromise={dispatchActionPromise}
noDataAfterPolicyAcknowledgment={noDataAfterPolicyAcknowledgment}
- socketCrashLoopRecovery={socketCrashLoopRecovery}
+ showSocketCrashLoopAlert={showSocketCrashLoopAlert}
lastCommunicatedPlatformDetails={lastCommunicatedPlatformDetails}
decompressSocketMessage={decompressMessage}
activeSessionRecovery={activeSessionRecovery}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Mon, Nov 25, 8:33 PM (19 h, 37 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2580686
Default Alt Text
D11217.id37750.diff (4 KB)
Attached To
Mode
D11217: [lib][native] Try session recovery on web too for policy acknowledgment crash loop
Attached
Detach File
Event Timeline
Log In to Comment