|
@@ -45,6 +45,7 @@ import { NAVIGATION_PAGES } from 'src/types';
|
|
|
import { useDeleteUserMutation } from '@api/app';
|
|
|
import { useNotification } from 'src/contexts/NotificationContext';
|
|
|
import { useMessagesStore } from 'src/stores/unreadMessagesStore';
|
|
|
+import { useAvatarStore } from 'src/stores/avatarVersionStore';
|
|
|
|
|
|
const ProfileSchema = yup.object({
|
|
|
username: yup.string().optional(),
|
|
@@ -76,7 +77,8 @@ export const EditPersonalInfo = () => {
|
|
|
const { data, error } = usePostGetProfileQuery(String(token), true);
|
|
|
const { updateNotificationStatus } = useNotification();
|
|
|
const updateUnreadMessagesCount = useMessagesStore((state) => state.updateUnreadMessagesCount);
|
|
|
-
|
|
|
+ const [isSubmitting, setIsSubmitting] = useState(false);
|
|
|
+ const {incrementAvatarVersion} = useAvatarStore();
|
|
|
|
|
|
const regions = useGetRegionsWithFlagQuery(true);
|
|
|
const [modalInfo, setModalInfo] = useState({
|
|
@@ -153,6 +155,8 @@ export const EditPersonalInfo = () => {
|
|
|
}
|
|
|
}}
|
|
|
onSubmit={async (values) => {
|
|
|
+ setIsSubmitting(true);
|
|
|
+
|
|
|
const profileData: PostSetProfileData = {
|
|
|
token: String(token),
|
|
|
user: {
|
|
@@ -184,7 +188,7 @@ export const EditPersonalInfo = () => {
|
|
|
};
|
|
|
}
|
|
|
|
|
|
- updateProfile(profileData, {
|
|
|
+ await updateProfile(profileData, {
|
|
|
onSuccess: () => {
|
|
|
queryClient.invalidateQueries({
|
|
|
queryKey: userQueryKeys.getProfileData(),
|
|
@@ -198,7 +202,13 @@ export const EditPersonalInfo = () => {
|
|
|
Image.clearDiskCache();
|
|
|
Image.clearMemoryCache();
|
|
|
|
|
|
+ incrementAvatarVersion();
|
|
|
+
|
|
|
+ setIsSubmitting(false);
|
|
|
navigation.goBack();
|
|
|
+ },
|
|
|
+ onError: () => {
|
|
|
+ setIsSubmitting(false);
|
|
|
}
|
|
|
});
|
|
|
}}
|
|
@@ -333,7 +343,7 @@ export const EditPersonalInfo = () => {
|
|
|
formikError={props.touched.other && props.errors.other}
|
|
|
/>
|
|
|
<View style={{ marginTop: 15, marginBottom: 15, gap: 8 }}>
|
|
|
- <Button onPress={props.handleSubmit}>Save</Button>
|
|
|
+ <Button onPress={props.handleSubmit} disabled={isSubmitting}>Save</Button>
|
|
|
<Button
|
|
|
variant={ButtonVariants.OPACITY}
|
|
|
containerStyles={{ backgroundColor: Colors.WHITE, borderColor: Colors.RED }}
|