Page MenuHomePhabricator

D10292.id34738.diff
No OneTemporary

D10292.id34738.diff

diff --git a/lib/actions/user-actions.js b/lib/actions/user-actions.js
--- a/lib/actions/user-actions.js
+++ b/lib/actions/user-actions.js
@@ -1,5 +1,8 @@
// @flow
+import * as React from 'react';
+
+import { preRequestUserStateSelector } from '../selectors/account-selectors.js';
import threadWatcher from '../shared/thread-watcher.js';
import type {
LogOutResult,
@@ -56,6 +59,7 @@
import { getConfig } from '../utils/config.js';
import type { CallKeyserverEndpoint } from '../utils/keyserver-call';
import { useKeyserverCall } from '../utils/keyserver-call.js';
+import { useSelector } from '../utils/redux-utils.js';
import sleep from '../utils/sleep.js';
import { ashoatKeyserverID } from '../utils/validation-utils.js';
@@ -93,8 +97,14 @@
return { currentUserInfo, preRequestUserState };
};
-function useLogOut(): (input: PreRequestUserState) => Promise<LogOutResult> {
- return useKeyserverCall(logOut);
+function useLogOut(): () => Promise<LogOutResult> {
+ const preRequestUserState = useSelector(preRequestUserStateSelector);
+ const callKeyserverLogOut = useKeyserverCall(logOut);
+
+ return React.useCallback(
+ () => callKeyserverLogOut(preRequestUserState),
+ [callKeyserverLogOut, preRequestUserState],
+ );
}
const claimUsernameActionTypes = Object.freeze({
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
@@ -111,7 +111,7 @@
+dispatch: Dispatch,
+dispatchActionPromise: DispatchActionPromise,
// async functions that hit server APIs
- +logOut: (preRequestUserState: PreRequestUserState) => Promise<LogOutResult>,
+ +logOut: () => Promise<LogOutResult>,
+socketCrashLoopRecovery?: () => Promise<void>,
// keyserver olm sessions specific props
+getInitialNotificationsEncryptedMessage?: () => Promise<string>,
@@ -695,7 +695,7 @@
console.log(error);
void this.props.dispatchActionPromise(
logOutActionTypes,
- this.props.logOut(this.props.preRequestUserState),
+ this.props.logOut(),
);
}
return;
@@ -717,7 +717,7 @@
if (e.message === 'not_logged_in') {
void this.props.dispatchActionPromise(
logOutActionTypes,
- this.props.logOut(this.props.preRequestUserState),
+ this.props.logOut(),
);
} else if (this.socket) {
this.socket.close();
diff --git a/native/components/version-supported.react.js b/native/components/version-supported.react.js
--- a/native/components/version-supported.react.js
+++ b/native/components/version-supported.react.js
@@ -3,10 +3,8 @@
import * as React from 'react';
import { useLogOut, logOutActionTypes } from 'lib/actions/user-actions.js';
-import { preRequestUserStateForSingleKeyserverSelector } from 'lib/selectors/account-selectors.js';
import { isLoggedIn } from 'lib/selectors/user-selectors.js';
import { useDispatchActionPromise } from 'lib/utils/action-utils.js';
-import { ashoatKeyserverID } from 'lib/utils/validation-utils.js';
import { commRustModule } from '../native-modules.js';
import { useSelector } from '../redux/redux-utils.js';
@@ -17,20 +15,14 @@
const hasRun = React.useRef(false);
const loggedIn = useSelector(isLoggedIn);
- const preRequestUserState = useSelector(
- preRequestUserStateForSingleKeyserverSelector(ashoatKeyserverID),
- );
const dispatchActionPromise = useDispatchActionPromise();
const callLogOut = useLogOut();
const onUsernameAlertAcknowledged = React.useCallback(() => {
if (loggedIn) {
- void dispatchActionPromise(
- logOutActionTypes,
- callLogOut(preRequestUserState),
- );
+ void dispatchActionPromise(logOutActionTypes, callLogOut());
}
- }, [callLogOut, dispatchActionPromise, loggedIn, preRequestUserState]);
+ }, [callLogOut, dispatchActionPromise, loggedIn]);
const checkVersionSupport = React.useCallback(async () => {
try {
diff --git a/native/profile/profile-screen.react.js b/native/profile/profile-screen.react.js
--- a/native/profile/profile-screen.react.js
+++ b/native/profile/profile-screen.react.js
@@ -5,11 +5,9 @@
import { logOutActionTypes, useLogOut } from 'lib/actions/user-actions.js';
import { useStringForUser } from 'lib/hooks/ens-cache.js';
-import { preRequestUserStateSelector } from 'lib/selectors/account-selectors.js';
import { createLoadingStatusSelector } from 'lib/selectors/loading-selectors.js';
import { accountHasPassword } from 'lib/shared/account-utils.js';
import type { LogOutResult } from 'lib/types/account-types.js';
-import { type PreRequestUserState } from 'lib/types/session-types.js';
import { type CurrentUserInfo } from 'lib/types/user-types.js';
import {
type DispatchActionPromise,
@@ -150,12 +148,11 @@
type Props = {
...BaseProps,
+currentUserInfo: ?CurrentUserInfo,
- +preRequestUserState: PreRequestUserState,
+logOutLoading: boolean,
+colors: Colors,
+styles: $ReadOnly<typeof unboundStyles>,
+dispatchActionPromise: DispatchActionPromise,
- +logOut: (preRequestUserState: PreRequestUserState) => Promise<LogOutResult>,
+ +logOut: () => Promise<LogOutResult>,
+staffCanSee: boolean,
+stringForUser: ?string,
+isAccountWithPassword: boolean,
@@ -362,7 +359,7 @@
logOut() {
void this.props.dispatchActionPromise(
logOutActionTypes,
- this.props.logOut(this.props.preRequestUserState),
+ this.props.logOut(),
);
}
@@ -431,7 +428,6 @@
const ConnectedProfileScreen: React.ComponentType<BaseProps> =
React.memo<BaseProps>(function ConnectedProfileScreen(props: BaseProps) {
const currentUserInfo = useSelector(state => state.currentUserInfo);
- const preRequestUserState = useSelector(preRequestUserStateSelector);
const logOutLoading =
useSelector(logOutLoadingStatusSelector) === 'loading';
const colors = useColors();
@@ -448,7 +444,6 @@
<ProfileScreen
{...props}
currentUserInfo={currentUserInfo}
- preRequestUserState={preRequestUserState}
logOutLoading={logOutLoading}
colors={colors}
styles={styles}
diff --git a/native/socket.react.js b/native/socket.react.js
--- a/native/socket.react.js
+++ b/native/socket.react.js
@@ -118,10 +118,7 @@
const socketCrashLoopRecovery = React.useCallback(async () => {
if (!accountHasPassword(currentUserInfo)) {
- void dispatchActionPromise(
- logOutActionTypes,
- callLogOut(preRequestUserState),
- );
+ void dispatchActionPromise(logOutActionTypes, callLogOut());
Alert.alert(
'Log in needed',
'After acknowledging the policies, we need you to log in to your account again',
@@ -144,7 +141,6 @@
currentUserInfo,
dispatch,
dispatchActionPromise,
- preRequestUserState,
urlPrefix,
getInitialNotificationsEncryptedMessage,
]);
diff --git a/web/settings/account-settings.react.js b/web/settings/account-settings.react.js
--- a/web/settings/account-settings.react.js
+++ b/web/settings/account-settings.react.js
@@ -6,7 +6,6 @@
import { useModalContext } from 'lib/components/modal-provider.react.js';
import SWMansionIcon from 'lib/components/SWMansionIcon.react.js';
import { useStringForUser } from 'lib/hooks/ens-cache.js';
-import { preRequestUserStateSelector } from 'lib/selectors/account-selectors.js';
import { accountHasPassword } from 'lib/shared/account-utils.js';
import { useTunnelbroker } from 'lib/tunnelbroker/tunnelbroker-context.js';
import { useDispatchActionPromise } from 'lib/utils/action-utils.js';
@@ -25,15 +24,10 @@
function AccountSettings(): React.Node {
const sendLogoutRequest = useLogOut();
- const preRequestUserState = useSelector(preRequestUserStateSelector);
const dispatchActionPromise = useDispatchActionPromise();
const logOutUser = React.useCallback(
- () =>
- dispatchActionPromise(
- logOutActionTypes,
- sendLogoutRequest(preRequestUserState),
- ),
- [dispatchActionPromise, preRequestUserState, sendLogoutRequest],
+ () => dispatchActionPromise(logOutActionTypes, sendLogoutRequest()),
+ [dispatchActionPromise, sendLogoutRequest],
);
const { pushModal, popModal } = useModalContext();

File Metadata

Mime Type
text/plain
Expires
Thu, Nov 28, 10:30 AM (20 h, 55 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2593386
Default Alt Text
D10292.id34738.diff (8 KB)

Event Timeline