Page MenuHomePhabricator

D11083.diff
No OneTemporary

D11083.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
@@ -429,24 +429,17 @@
success: 'IDENTITY_REGISTER_SUCCESS',
failed: 'IDENTITY_REGISTER_FAILED',
});
-function useIdentityRegister(): (
+function useIdentityPasswordRegister(): (
username: string,
password: string,
) => Promise<IdentityAuthResult> {
const client = React.useContext(IdentityClientContext);
const identityClient = client?.identityClient;
- return React.useCallback(
- (username, password) => {
- if (!identityClient) {
- throw new Error('Identity service client is not initialized');
- }
- if (!identityClient.registerPasswordUser) {
- throw new Error('Register user method unimplemented');
- }
- return identityClient.registerPasswordUser(username, password);
- },
- [identityClient],
- );
+ invariant(identityClient, 'Identity client should be set');
+ if (!identityClient.registerPasswordUser) {
+ throw new Error('Register user method unimplemented');
+ }
+ return identityClient.registerPasswordUser;
}
const identityGenerateNonceActionTypes = Object.freeze({
@@ -854,7 +847,7 @@
keyserverAuthActionTypes,
useKeyserverAuth,
identityRegisterActionTypes,
- useIdentityRegister,
+ useIdentityPasswordRegister,
identityGenerateNonceActionTypes,
useIdentityGenerateNonce,
};
diff --git a/native/account/registration/registration-server-call.js b/native/account/registration/registration-server-call.js
--- a/native/account/registration/registration-server-call.js
+++ b/native/account/registration/registration-server-call.js
@@ -6,7 +6,7 @@
import {
keyserverRegisterActionTypes,
keyserverRegister,
- useIdentityRegister,
+ useIdentityPasswordRegister,
identityRegisterActionTypes,
} from 'lib/actions/user-actions.js';
import type { LogInStartingPayload } from 'lib/types/account-types.js';
@@ -68,13 +68,13 @@
const dispatchActionPromise = useDispatchActionPromise();
const callKeyserverRegister = useLegacyAshoatKeyserverCall(keyserverRegister);
- const callIdentityRegister = useIdentityRegister();
+ const callIdentityPasswordRegister = useIdentityPasswordRegister();
const identityRegisterUsernameAccount = React.useCallback(
async (accountSelection: UsernameAccountSelection) => {
const identityRegisterPromise = (async () => {
try {
- const result = await callIdentityRegister(
+ const result = await callIdentityPasswordRegister(
accountSelection.username,
accountSelection.password,
);
@@ -114,7 +114,7 @@
);
await identityRegisterPromise;
},
- [callIdentityRegister, dispatchActionPromise],
+ [callIdentityPasswordRegister, dispatchActionPromise],
);
const keyserverRegisterUsernameAccount = React.useCallback(

File Metadata

Mime Type
text/plain
Expires
Mon, Nov 25, 7:12 AM (20 h, 20 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2578900
Default Alt Text
D11083.diff (2 KB)

Event Timeline