Skip to content
Open
Changes from 2 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
24 changes: 21 additions & 3 deletions app/views/ProfileView/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { type NativeStackNavigationOptions, type NativeStackNavigationProp } from '@react-navigation/native-stack';
import { sha256 } from 'js-sha256';
import React, { useCallback, useLayoutEffect, useRef, useState } from 'react';
import React, { useCallback, useEffect, useLayoutEffect, useRef, useState } from 'react';
import { Keyboard, ScrollView, View, type TextInput } from 'react-native';
import { useDispatch } from 'react-redux';
import * as yup from 'yup';
Expand Down Expand Up @@ -282,10 +282,28 @@ const ProfileView = ({ navigation }: IProfileViewProps): React.ReactElement => {

useFocusEffect(
useCallback(() => {
reset();
}, [])
reset({
name: user?.name as string,
username: user?.username,
email: user?.emails?.[0]?.address || null,
currentPassword: null,
newPassword: null,
avatar: null
});
}, [user?.name, user?.username, user?.emails, reset])
);

// Sync form values when user data loads (fixes race condition on app startup)
useEffect(() => {
if (user?.emails?.[0]?.address) {
const currentEmail = getValues('email');
// Only update if email is missing/null but user has email data
if (!currentEmail) {
setValue('email', user.emails[0].address, { shouldValidate: false, shouldDirty: false });
}
}
}, [user?.emails, setValue, getValues]);

return (
<KeyboardView>
<SafeAreaView testID='profile-view'>
Expand Down