Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3523986
D13308.id44176.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
23 KB
Referenced Files
None
Subscribers
None
D13308.id44176.diff
View Options
diff --git a/native/account/fullscreen-siwe-panel.react.js b/native/account/fullscreen-siwe-panel.react.js
--- a/native/account/fullscreen-siwe-panel.react.js
+++ b/native/account/fullscreen-siwe-panel.react.js
@@ -14,7 +14,6 @@
import { useGetEthereumAccountFromSIWEResult } from './registration/ethereum-utils.js';
import { RegistrationContext } from './registration/registration-context.js';
-import { enableNewRegistrationMode } from './registration/registration-types.js';
import { useLegacySIWEServerCall } from './siwe-hooks.js';
import SIWEPanel from './siwe-panel.react.js';
import { commRustModule } from '../native-modules.js';
@@ -48,8 +47,7 @@
const registrationContext = React.useContext(RegistrationContext);
invariant(registrationContext, 'registrationContext should be set');
- const { setSkipEthereumLoginOnce, register: registrationServerCall } =
- registrationContext;
+ const { setSkipEthereumLoginOnce } = registrationContext;
const getEthereumAccountFromSIWEResult =
useGetEthereumAccountFromSIWEResult();
@@ -123,26 +121,8 @@
throw e;
}
}
- } else if (enableNewRegistrationMode) {
- await onAccountDoesNotExist(result);
} else {
- try {
- await registrationServerCall({
- farcasterID: null,
- accountSelection: {
- accountType: 'ethereum',
- ...result,
- avatarURI: null,
- },
- avatarData: null,
- clearCachedSelections: () => {},
- onNonceExpired: () => onNonceExpired('registration'),
- onAlertAcknowledged: goBackToPrompt,
- });
- } catch {
- // We swallow exceptions here because registrationServerCall
- // already handles showing Alerts, and we don't want to show two
- }
+ await onAccountDoesNotExist(result);
}
} catch (e) {
Alert.alert(
@@ -156,7 +136,7 @@
try {
await legacySiweServerCall({
...result,
- doNotRegister: enableNewRegistrationMode,
+ doNotRegister: true,
});
} catch (e) {
if (
@@ -194,7 +174,6 @@
},
[
walletLogIn,
- registrationServerCall,
goBackToPrompt,
dispatch,
legacySiweServerCall,
diff --git a/native/account/legacy-register-panel.react.js b/native/account/legacy-register-panel.react.js
deleted file mode 100644
--- a/native/account/legacy-register-panel.react.js
+++ /dev/null
@@ -1,508 +0,0 @@
-// @flow
-
-import invariant from 'invariant';
-import * as React from 'react';
-import {
- Text,
- View,
- StyleSheet,
- Platform,
- Keyboard,
- Linking,
-} from 'react-native';
-
-import { setDataLoadedActionType } from 'lib/actions/client-db-store-actions.js';
-import {
- legacyKeyserverRegisterActionTypes,
- legacyKeyserverRegister,
- getOlmSessionInitializationDataActionTypes,
-} from 'lib/actions/user-actions.js';
-import { useLegacyAshoatKeyserverCall } from 'lib/keyserver-conn/legacy-keyserver-call.js';
-import {
- createLoadingStatusSelector,
- combineLoadingStatuses,
-} from 'lib/selectors/loading-selectors.js';
-import { validUsernameRegex } from 'lib/shared/account-utils.js';
-import { useInitialNotificationsEncryptedMessage } from 'lib/shared/crypto-utils.js';
-import type {
- LegacyRegisterInfo,
- LegacyLogInExtraInfo,
- LegacyRegisterResult,
- LegacyLogInStartingPayload,
-} from 'lib/types/account-types.js';
-import type { LoadingStatus } from 'lib/types/loading-types.js';
-import type { Dispatch } from 'lib/types/redux-types.js';
-import {
- useDispatchActionPromise,
- type DispatchActionPromise,
-} from 'lib/utils/redux-promise-utils.js';
-import { useDispatch } from 'lib/utils/redux-utils.js';
-
-import { TextInput } from './modal-components.react.js';
-import { setNativeCredentials } from './native-credentials.js';
-import { PanelButton, Panel } from './panel-components.react.js';
-import { authoritativeKeyserverID } from '../authoritative-keyserver.js';
-import SWMansionIcon from '../components/swmansion-icon.react.js';
-import { useSelector } from '../redux/redux-utils.js';
-import { nativeLegacyLogInExtraInfoSelector } from '../selectors/account-selectors.js';
-import type { KeyPressEvent } from '../types/react-native.js';
-import type { ViewStyle } from '../types/styles.js';
-import {
- appOutOfDateAlertDetails,
- usernameReservedAlertDetails,
- usernameTakenAlertDetails,
- unknownErrorAlertDetails,
-} from '../utils/alert-messages.js';
-import Alert from '../utils/alert.js';
-import { type StateContainer } from '../utils/state-container.js';
-
-type WritableLegacyRegisterState = {
- usernameInputText: string,
- passwordInputText: string,
- confirmPasswordInputText: string,
-};
-export type LegacyRegisterState = $ReadOnly<WritableLegacyRegisterState>;
-type BaseProps = {
- +setActiveAlert: (activeAlert: boolean) => void,
- +opacityStyle: ViewStyle,
- +legacyRegisterState: StateContainer<LegacyRegisterState>,
-};
-type Props = {
- ...BaseProps,
- +loadingStatus: LoadingStatus,
- +legacyLogInExtraInfo: () => Promise<LegacyLogInExtraInfo>,
- +dispatch: Dispatch,
- +dispatchActionPromise: DispatchActionPromise,
- +legacyRegister: (
- registerInfo: LegacyRegisterInfo,
- ) => Promise<LegacyRegisterResult>,
- +getInitialNotificationsEncryptedMessage: () => Promise<string>,
-};
-type State = {
- +confirmPasswordFocused: boolean,
-};
-class LegacyRegisterPanel extends React.PureComponent<Props, State> {
- state: State = {
- confirmPasswordFocused: false,
- };
- usernameInput: ?TextInput;
- passwordInput: ?TextInput;
- confirmPasswordInput: ?TextInput;
- passwordBeingAutoFilled = false;
-
- render(): React.Node {
- let confirmPasswordTextInputExtraProps;
- if (
- Platform.OS !== 'ios' ||
- this.state.confirmPasswordFocused ||
- this.props.legacyRegisterState.state.confirmPasswordInputText.length > 0
- ) {
- confirmPasswordTextInputExtraProps = {
- secureTextEntry: true,
- textContentType: 'password',
- };
- }
-
- let onPasswordKeyPress;
- if (Platform.OS === 'ios') {
- onPasswordKeyPress = this.onPasswordKeyPress;
- }
-
- const privatePolicyNotice = (
- <View style={styles.notice}>
- <Text style={styles.noticeText}>
- By signing up, you agree to our{' '}
- <Text style={styles.hyperlinkText} onPress={this.onTermsOfUsePressed}>
- Terms
- </Text>
- {' & '}
- <Text
- style={styles.hyperlinkText}
- onPress={this.onPrivacyPolicyPressed}
- >
- Privacy Policy
- </Text>
- .
- </Text>
- </View>
- );
-
- return (
- <Panel opacityStyle={this.props.opacityStyle} style={styles.container}>
- <View style={styles.row}>
- <SWMansionIcon
- name="user-1"
- size={22}
- color="#555"
- style={styles.icon}
- />
- <TextInput
- style={styles.input}
- value={this.props.legacyRegisterState.state.usernameInputText}
- onChangeText={this.onChangeUsernameInputText}
- placeholder="Username"
- autoFocus={true}
- autoCorrect={false}
- autoCapitalize="none"
- keyboardType="ascii-capable"
- textContentType="username"
- autoComplete="username-new"
- returnKeyType="next"
- blurOnSubmit={false}
- onSubmitEditing={this.focusPasswordInput}
- editable={this.props.loadingStatus !== 'loading'}
- ref={this.usernameInputRef}
- />
- </View>
- <View style={styles.row}>
- <SWMansionIcon
- name="lock-on"
- size={22}
- color="#555"
- style={styles.icon}
- />
- <TextInput
- style={styles.input}
- value={this.props.legacyRegisterState.state.passwordInputText}
- onChangeText={this.onChangePasswordInputText}
- onKeyPress={onPasswordKeyPress}
- placeholder="Password"
- autoCapitalize="none"
- secureTextEntry={true}
- textContentType="password"
- autoComplete="password-new"
- returnKeyType="next"
- blurOnSubmit={false}
- onSubmitEditing={this.focusConfirmPasswordInput}
- editable={this.props.loadingStatus !== 'loading'}
- ref={this.passwordInputRef}
- />
- </View>
- <View style={styles.row}>
- <TextInput
- style={styles.input}
- value={
- this.props.legacyRegisterState.state.confirmPasswordInputText
- }
- onChangeText={this.onChangeConfirmPasswordInputText}
- placeholder="Confirm password"
- autoCapitalize="none"
- autoComplete="password-new"
- returnKeyType="go"
- blurOnSubmit={false}
- onSubmitEditing={this.onSubmit}
- onFocus={this.onConfirmPasswordFocus}
- editable={this.props.loadingStatus !== 'loading'}
- ref={this.confirmPasswordInputRef}
- {...confirmPasswordTextInputExtraProps}
- />
- </View>
- <View style={styles.footer}>
- {privatePolicyNotice}
- <PanelButton
- text="SIGN UP"
- loadingStatus={this.props.loadingStatus}
- onSubmit={this.onSubmit}
- />
- </View>
- </Panel>
- );
- }
-
- usernameInputRef = (usernameInput: ?TextInput) => {
- this.usernameInput = usernameInput;
- };
-
- passwordInputRef = (passwordInput: ?TextInput) => {
- this.passwordInput = passwordInput;
- };
-
- confirmPasswordInputRef = (confirmPasswordInput: ?TextInput) => {
- this.confirmPasswordInput = confirmPasswordInput;
- };
-
- focusUsernameInput = () => {
- invariant(this.usernameInput, 'ref should be set');
- this.usernameInput.focus();
- };
-
- focusPasswordInput = () => {
- invariant(this.passwordInput, 'ref should be set');
- this.passwordInput.focus();
- };
-
- focusConfirmPasswordInput = () => {
- invariant(this.confirmPasswordInput, 'ref should be set');
- this.confirmPasswordInput.focus();
- };
-
- onTermsOfUsePressed = () => {
- void Linking.openURL('https://comm.app/terms');
- };
-
- onPrivacyPolicyPressed = () => {
- void Linking.openURL('https://comm.app/privacy');
- };
-
- onChangeUsernameInputText = (text: string) => {
- this.props.legacyRegisterState.setState({ usernameInputText: text });
- };
-
- onChangePasswordInputText = (text: string) => {
- const stateUpdate: Partial<WritableLegacyRegisterState> = {};
- stateUpdate.passwordInputText = text;
- if (this.passwordBeingAutoFilled) {
- this.passwordBeingAutoFilled = false;
- stateUpdate.confirmPasswordInputText = text;
- }
- this.props.legacyRegisterState.setState(stateUpdate);
- };
-
- onPasswordKeyPress = (event: KeyPressEvent) => {
- const { key } = event.nativeEvent;
- if (
- key.length > 1 &&
- key !== 'Backspace' &&
- key !== 'Enter' &&
- this.props.legacyRegisterState.state.confirmPasswordInputText.length === 0
- ) {
- this.passwordBeingAutoFilled = true;
- }
- };
-
- onChangeConfirmPasswordInputText = (text: string) => {
- this.props.legacyRegisterState.setState({ confirmPasswordInputText: text });
- };
-
- onConfirmPasswordFocus = () => {
- this.setState({ confirmPasswordFocused: true });
- };
-
- onSubmit = async () => {
- this.props.setActiveAlert(true);
- if (this.props.legacyRegisterState.state.passwordInputText === '') {
- Alert.alert(
- 'Empty password',
- 'Password cannot be empty',
- [{ text: 'OK', onPress: this.onPasswordAlertAcknowledged }],
- { cancelable: false },
- );
- } else if (
- this.props.legacyRegisterState.state.passwordInputText !==
- this.props.legacyRegisterState.state.confirmPasswordInputText
- ) {
- Alert.alert(
- 'Passwords don’t match',
- 'Password fields must contain the same password',
- [{ text: 'OK', onPress: this.onPasswordAlertAcknowledged }],
- { cancelable: false },
- );
- } else if (
- this.props.legacyRegisterState.state.usernameInputText.search(
- validUsernameRegex,
- ) === -1
- ) {
- Alert.alert(
- 'Invalid username',
- 'Usernames must be at least six characters long, start with either a ' +
- 'letter or a number, and may contain only letters, numbers, or the ' +
- 'characters “-” and “_”',
- [{ text: 'OK', onPress: this.onUsernameAlertAcknowledged }],
- { cancelable: false },
- );
- } else {
- Keyboard.dismiss();
- const extraInfo = await this.props.legacyLogInExtraInfo();
- const initialNotificationsEncryptedMessage =
- await this.props.getInitialNotificationsEncryptedMessage();
- void this.props.dispatchActionPromise(
- legacyKeyserverRegisterActionTypes,
- this.legacyRegisterAction({
- ...extraInfo,
- initialNotificationsEncryptedMessage,
- }),
- undefined,
- ({
- calendarQuery: extraInfo.calendarQuery,
- }: LegacyLogInStartingPayload),
- );
- }
- };
-
- onPasswordAlertAcknowledged = () => {
- this.props.setActiveAlert(false);
- this.props.legacyRegisterState.setState(
- {
- passwordInputText: '',
- confirmPasswordInputText: '',
- },
- () => {
- invariant(this.passwordInput, 'ref should exist');
- this.passwordInput.focus();
- },
- );
- };
-
- onUsernameAlertAcknowledged = () => {
- this.props.setActiveAlert(false);
- this.props.legacyRegisterState.setState(
- {
- usernameInputText: '',
- },
- () => {
- invariant(this.usernameInput, 'ref should exist');
- this.usernameInput.focus();
- },
- );
- };
-
- async legacyRegisterAction(
- extraInfo: LegacyLogInExtraInfo,
- ): Promise<LegacyRegisterResult> {
- try {
- const result = await this.props.legacyRegister({
- ...extraInfo,
- username: this.props.legacyRegisterState.state.usernameInputText,
- password: this.props.legacyRegisterState.state.passwordInputText,
- });
- this.props.setActiveAlert(false);
- this.props.dispatch({
- type: setDataLoadedActionType,
- payload: {
- dataLoaded: true,
- },
- });
- await setNativeCredentials({
- username: result.currentUserInfo.username,
- password: this.props.legacyRegisterState.state.passwordInputText,
- });
- return result;
- } catch (e) {
- if (e.message === 'username_reserved') {
- Alert.alert(
- usernameReservedAlertDetails.title,
- usernameReservedAlertDetails.message,
- [{ text: 'OK', onPress: this.onUsernameAlertAcknowledged }],
- { cancelable: false },
- );
- } else if (e.message === 'username_taken') {
- Alert.alert(
- usernameTakenAlertDetails.title,
- usernameTakenAlertDetails.message,
- [{ text: 'OK', onPress: this.onUsernameAlertAcknowledged }],
- { cancelable: false },
- );
- } else if (e.message === 'client_version_unsupported') {
- Alert.alert(
- appOutOfDateAlertDetails.title,
- appOutOfDateAlertDetails.message,
- [{ text: 'OK', onPress: this.onOtherErrorAlertAcknowledged }],
- { cancelable: false },
- );
- } else {
- Alert.alert(
- unknownErrorAlertDetails.title,
- unknownErrorAlertDetails.message,
- [{ text: 'OK', onPress: this.onOtherErrorAlertAcknowledged }],
- { cancelable: false },
- );
- }
- throw e;
- }
- }
-
- onOtherErrorAlertAcknowledged = () => {
- this.props.setActiveAlert(false);
- };
-}
-
-const styles = StyleSheet.create({
- container: {
- zIndex: 2,
- },
- footer: {
- alignItems: 'stretch',
- flexDirection: 'row',
- flexShrink: 1,
- justifyContent: 'space-between',
- paddingLeft: 24,
- },
- hyperlinkText: {
- color: '#036AFF',
- fontWeight: 'bold',
- },
- icon: {
- bottom: 10,
- left: 4,
- position: 'absolute',
- },
- input: {
- paddingLeft: 35,
- },
- notice: {
- alignSelf: 'center',
- display: 'flex',
- flexShrink: 1,
- maxWidth: 190,
- paddingBottom: 18,
- paddingRight: 8,
- paddingTop: 12,
- },
- noticeText: {
- color: '#444',
- fontSize: 13,
- lineHeight: 20,
- textAlign: 'center',
- },
- row: {
- marginHorizontal: 24,
- },
-});
-
-const registerLoadingStatusSelector = createLoadingStatusSelector(
- legacyKeyserverRegisterActionTypes,
-);
-const olmSessionInitializationDataLoadingStatusSelector =
- createLoadingStatusSelector(getOlmSessionInitializationDataActionTypes);
-
-const ConnectedLegacyRegisterPanel: React.ComponentType<BaseProps> =
- React.memo<BaseProps>(function ConnectedLegacyRegisterPanel(
- props: BaseProps,
- ) {
- const registerLoadingStatus = useSelector(registerLoadingStatusSelector);
- const olmSessionInitializationDataLoadingStatus = useSelector(
- olmSessionInitializationDataLoadingStatusSelector,
- );
- const loadingStatus = combineLoadingStatuses(
- registerLoadingStatus,
- olmSessionInitializationDataLoadingStatus,
- );
-
- const legacyLogInExtraInfo = useSelector(
- nativeLegacyLogInExtraInfoSelector,
- );
-
- const dispatch = useDispatch();
- const dispatchActionPromise = useDispatchActionPromise();
- const callLegacyRegister = useLegacyAshoatKeyserverCall(
- legacyKeyserverRegister,
- );
- const getInitialNotificationsEncryptedMessage =
- useInitialNotificationsEncryptedMessage(authoritativeKeyserverID);
-
- return (
- <LegacyRegisterPanel
- {...props}
- loadingStatus={loadingStatus}
- legacyLogInExtraInfo={legacyLogInExtraInfo}
- dispatch={dispatch}
- dispatchActionPromise={dispatchActionPromise}
- legacyRegister={callLegacyRegister}
- getInitialNotificationsEncryptedMessage={
- getInitialNotificationsEncryptedMessage
- }
- />
- );
- });
-
-export default ConnectedLegacyRegisterPanel;
diff --git a/native/account/logged-out-modal.react.js b/native/account/logged-out-modal.react.js
--- a/native/account/logged-out-modal.react.js
+++ b/native/account/logged-out-modal.react.js
@@ -30,12 +30,9 @@
import { splashBackgroundURI } from './background-info.js';
import FullscreenSIWEPanel from './fullscreen-siwe-panel.react.js';
-import LegacyRegisterPanel from './legacy-register-panel.react.js';
-import type { LegacyRegisterState } from './legacy-register-panel.react.js';
import LogInPanel from './log-in-panel.react.js';
import type { LogInState } from './log-in-panel.react.js';
import LoggedOutStaffInfo from './logged-out-staff-info.react.js';
-import { enableNewRegistrationMode } from './registration/registration-types.js';
import { authoritativeKeyserverID } from '../authoritative-keyserver.js';
import KeyboardAvoidingView from '../components/keyboard-avoiding-view.react.js';
import ConnectedStatusBar from '../connected-status-bar.react.js';
@@ -60,12 +57,7 @@
let initialAppLoad = true;
const safeAreaEdges = ['top', 'bottom'];
-export type LoggedOutMode =
- | 'loading'
- | 'prompt'
- | 'log-in'
- | 'register'
- | 'siwe';
+export type LoggedOutMode = 'loading' | 'prompt' | 'log-in' | 'siwe';
const timingConfig = {
duration: 250,
@@ -85,8 +77,6 @@
containerSize += Platform.OS === 'ios' ? 40 : 61;
} else if (modeValue === 'log-in') {
containerSize += 140;
- } else if (modeValue === 'register') {
- containerSize += Platform.OS === 'ios' ? 181 : 180;
} else if (modeValue === 'siwe') {
containerSize += 250;
}
@@ -232,11 +222,6 @@
usernameInputText: null,
passwordInputText: null,
};
-const initialLegacyRegisterState = {
- usernameInputText: '',
- passwordInputText: '',
- confirmPasswordInputText: '',
-};
type Mode = {
+curMode: LoggedOutMode,
@@ -278,28 +263,6 @@
[logInState, setLogInState],
);
- const [legacyRegisterState, baseSetLegacyRegisterState] =
- React.useState<LegacyRegisterState>(initialLegacyRegisterState);
- const setLegacyRegisterState = React.useCallback(
- (newLegacyRegisterState: Partial<LegacyRegisterState>) => {
- if (!mountedRef.current) {
- return;
- }
- baseSetLegacyRegisterState(prevLegacyRegisterState => ({
- ...prevLegacyRegisterState,
- ...newLegacyRegisterState,
- }));
- },
- [],
- );
- const legacyRegisterStateContainer = React.useMemo(
- () => ({
- state: legacyRegisterState,
- setState: setLegacyRegisterState,
- }),
- [legacyRegisterState, setLegacyRegisterState],
- );
-
const persistedStateLoaded = usePersistedStateLoaded();
const initialMode = persistedStateLoaded ? 'prompt' : 'loading';
const [mode, baseSetMode] = React.useState(() => ({
@@ -468,10 +431,6 @@
navigate(QRCodeSignInNavigatorRouteName);
}, [navigate]);
- const onPressRegister = React.useCallback(() => {
- combinedSetMode('register');
- }, [combinedSetMode]);
-
const onPressNewRegister = React.useCallback(() => {
navigate(RegistrationRouteName);
}, [navigate]);
@@ -490,14 +449,6 @@
logInState={logInStateContainer}
/>
);
- } else if (mode.curMode === 'register') {
- return (
- <LegacyRegisterPanel
- setActiveAlert={setActiveAlert}
- opacityStyle={opacityStyle}
- legacyRegisterState={legacyRegisterStateContainer}
- />
- );
} else if (mode.curMode === 'loading') {
return (
<ActivityIndicator
@@ -513,7 +464,6 @@
setActiveAlert,
opacityStyle,
logInStateContainer,
- legacyRegisterStateContainer,
styles.loadingIndicator,
]);
@@ -545,30 +495,6 @@
return null;
}
- const registerButtons = [];
- registerButtons.push(
- <TouchableOpacity
- onPress={onPressRegister}
- style={classicAuthButtonStyle}
- activeOpacity={0.6}
- key="old"
- >
- <Text style={classicAuthButtonTextStyle}>Register</Text>
- </TouchableOpacity>,
- );
- if (enableNewRegistrationMode) {
- registerButtons.push(
- <TouchableOpacity
- onPress={onPressNewRegister}
- style={classicAuthButtonStyle}
- activeOpacity={0.6}
- key="new"
- >
- <Text style={classicAuthButtonTextStyle}>Register (new)</Text>
- </TouchableOpacity>,
- );
- }
-
const signInButtons = [];
signInButtons.push(
<TouchableOpacity
@@ -612,12 +538,20 @@
<View style={styles.siweOrRightHR} />
</View>
<View style={styles.signInButtons}>{signInButtons}</View>
- <View style={styles.registerButtons}>{registerButtons}</View>
+ <View style={styles.registerButtons}>
+ <TouchableOpacity
+ onPress={onPressNewRegister}
+ style={classicAuthButtonStyle}
+ activeOpacity={0.6}
+ key="new"
+ >
+ <Text style={classicAuthButtonTextStyle}>Register</Text>
+ </TouchableOpacity>
+ </View>
</AnimatedView>
);
}, [
mode.curMode,
- onPressRegister,
onPressNewRegister,
onPressLogIn,
onPressQRCodeSignIn,
diff --git a/native/account/registration/registration-types.js b/native/account/registration/registration-types.js
--- a/native/account/registration/registration-types.js
+++ b/native/account/registration/registration-types.js
@@ -66,6 +66,4 @@
clientAvatar: { type: 'ens' },
};
-export const enableNewRegistrationMode = __DEV__;
-
export const enableSIWEBackupCreation = __DEV__;
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Tue, Dec 24, 10:56 AM (17 h, 14 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2698819
Default Alt Text
D13308.id44176.diff (23 KB)
Attached To
Mode
D13308: [native] Launch new registration flow and deprecate old one
Attached
Detach File
Event Timeline
Log In to Comment