Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3361733
D11216.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
5 KB
Referenced Files
None
Subscribers
None
D11216.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
@@ -109,7 +109,7 @@
+dispatch: Dispatch,
+dispatchActionPromise: DispatchActionPromise,
// async functions that hit server APIs
- +socketCrashLoopRecovery?: () => Promise<void>,
+ +socketCrashLoopRecovery?: () => mixed,
};
type State = {
+inflightRequests: ?InflightRequests,
@@ -668,18 +668,7 @@
this.props.socketCrashLoopRecovery
) {
this.failuresAfterPolicyAcknowledgment = 0;
- try {
- await this.props.socketCrashLoopRecovery();
- } catch (error) {
- console.log(error);
- this.props.dispatch({
- type: setConnectionIssueActionType,
- payload: {
- keyserverID: this.props.keyserverID,
- connectionIssue: 'policy_acknowledgement_socket_crash_loop',
- },
- });
- }
+ this.props.socketCrashLoopRecovery();
return;
}
diff --git a/lib/types/socket-types.js b/lib/types/socket-types.js
--- a/lib/types/socket-types.js
+++ b/lib/types/socket-types.js
@@ -493,9 +493,7 @@
| 'forcedDisconnecting'
| 'disconnected';
-export type ConnectionIssue =
- | 'policy_acknowledgement_socket_crash_loop'
- | 'not_logged_in_error';
+export type ConnectionIssue = 'not_logged_in_error';
export type ConnectionInfo = {
+status: ConnectionStatus,
@@ -520,12 +518,7 @@
queuedActivityUpdates: t.list(activityUpdateValidator),
lateResponses: t.list(t.Number),
unreachable: t.Boolean,
- connectionIssue: t.maybe(
- t.enums.of([
- 'policy_acknowledgement_socket_crash_loop',
- 'not_logged_in_error',
- ]),
- ),
+ connectionIssue: t.maybe(t.enums.of(['not_logged_in_error'])),
activeSessionRecovery: t.maybe(t.enums.of(values(recoveryActionSources))),
});
export const defaultConnectionInfo: ConnectionInfo = {
diff --git a/native/socket.react.js b/native/socket.react.js
--- a/native/socket.react.js
+++ b/native/socket.react.js
@@ -3,12 +3,11 @@
import invariant from 'invariant';
import * as React from 'react';
-import { setConnectionIssueActionType } from 'lib/keyserver-conn/keyserver-conn-types.js';
-import { resolveKeyserverSessionInvalidation } from 'lib/keyserver-conn/recovery-utils.js';
+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 {
cookieSelector,
- urlPrefixSelector,
connectionSelector,
lastCommunicatedPlatformDetailsSelector,
} from 'lib/selectors/keyserver-selectors.js';
@@ -20,6 +19,7 @@
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';
import {
activeMessageListSelector,
@@ -44,8 +44,6 @@
const { keyserverID } = props;
const cookie = useSelector(cookieSelector(keyserverID));
- const urlPrefix = useSelector(urlPrefixSelector(keyserverID));
- invariant(urlPrefix, 'missing urlPrefix for given keyserver id');
const connection = useSelector(connectionSelector(keyserverID));
invariant(connection, 'keyserver missing from keyserverStore');
const frozen = useSelector(state => state.frozen);
@@ -106,39 +104,28 @@
const dispatch = useDispatch();
const dispatchActionPromise = useDispatchActionPromise();
- const socketCrashLoopRecovery = React.useCallback(async () => {
- if (!accountHasPassword(currentUserInfo)) {
- void dispatch({
- type: setConnectionIssueActionType,
- payload: {
- keyserverID,
- connectionIssue: 'policy_acknowledgement_socket_crash_loop',
- },
- });
+ const hasPassword = accountHasPassword(currentUserInfo);
+ const socketCrashLoopRecovery = React.useCallback(() => {
+ if (
+ !canResolveKeyserverSessionInvalidation() ||
+ (!hasPassword && !usingCommServicesAccessToken)
+ ) {
Alert.alert(
'Log in needed',
- 'After acknowledging the policies, we need you to log in to your account again',
+ 'After acknowledging the policies, we need you to log in to your ' +
+ 'account again',
[{ text: 'OK' }],
);
- return;
}
-
- await resolveKeyserverSessionInvalidation(
- dispatch,
- cookie,
- urlPrefix,
- recoveryActionSources.refetchUserDataAfterAcknowledgment,
- keyserverID,
- getInitialNotificationsEncryptedMessage,
- );
- }, [
- cookie,
- currentUserInfo,
- dispatch,
- urlPrefix,
- getInitialNotificationsEncryptedMessage,
- keyserverID,
- ]);
+ dispatch({
+ type: setActiveSessionRecoveryActionType,
+ payload: {
+ activeSessionRecovery:
+ recoveryActionSources.refetchUserDataAfterAcknowledgment,
+ keyserverID,
+ },
+ });
+ }, [hasPassword, dispatch, keyserverID]);
const activeSessionRecovery = useSelector(
state =>
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Mon, Nov 25, 7:05 PM (19 h, 37 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2580752
Default Alt Text
D11216.diff (5 KB)
Attached To
Mode
D11216: [lib][native] Use unified keyserver session recovery in native/socket.react.js
Attached
Detach File
Event Timeline
Log In to Comment