Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: add Name field to SetUsernameView #6144

Merged
merged 3 commits into from
Feb 20, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/lib/services/restApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -626,7 +626,7 @@ export const saveRoomSettings = (
sdk.methodCallWrapper('saveRoomSettings', rid, params);

export const saveUserProfile = (
data: IProfileParams | Pick<IProfileParams, 'username'>,
data: IProfileParams | Pick<IProfileParams, 'username' | 'name'>,
customFields?: { [key: string | number]: string }
) =>
// RC 0.62.2
Expand Down
28 changes: 25 additions & 3 deletions app/views/SetUsernameView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,12 @@ const styles = StyleSheet.create({

interface ISubmit {
username: string;
name: string;
}

const schema = yup.object().shape({
username: yup.string().required()
username: yup.string().required(),
name: yup.string().required()
});

const SetUsernameView = () => {
Expand Down Expand Up @@ -67,13 +69,13 @@ const SetUsernameView = () => {
init();
}, []);

const submit = async ({ username }: ISubmit) => {
const submit = async ({ username, name }: ISubmit) => {
if (!isValid) {
return;
}
setLoading(true);
try {
await Services.saveUserProfile({ username });
await Services.saveUserProfile({ username, name });
dispatch(loginRequest({ resume: token }));
} catch (e: any) {
showErrorAlert(e.message, I18n.t('Oops'));
Expand Down Expand Up @@ -103,6 +105,26 @@ const SetUsernameView = () => {
clearButtonMode='while-editing'
containerStyle={sharedStyles.inputLastChild}
/>
<Text
style={[
sharedStyles.loginTitle,
sharedStyles.textBold,
styles.loginTitle,
{ color: colors.fontTitlesLabels, marginBottom: 10 }
]}>
{I18n.t('Name')}
</Text>
<ControlledFormTextInput
control={control}
name='name'
autoFocus
placeholder={I18n.t('Name')}
returnKeyType='send'
onSubmitEditing={handleSubmit(submit)}
testID='set-name-view-input'
clearButtonMode='while-editing'
containerStyle={sharedStyles.inputLastChild}
/>
<Button
title={I18n.t('Register')}
type='primary'
Expand Down