Skip to content

Commit

Permalink
fix sending unchnaged videoLink every time to server
Browse files Browse the repository at this point in the history
  • Loading branch information
luiqor committed Nov 23, 2024
1 parent b728ed6 commit 6ea36f0
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions src/pages/edit-profile/EditProfile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,17 +76,17 @@ const EditProfile = () => {
const isPasswordSecurityTab =
activeTab === UserProfileTabsEnum.PasswordAndSecurity

const areAllValuesEmptyStrings = (
obj: DataByRole<string> | { [key: string]: string }
): boolean => {
const areAllValuesEmptyStrings = (obj: {
[key: string]: string
}): boolean => {
return Object.values(obj).every(
(value) => typeof value === 'string' && value === ''
)
}

const hasChanges = (
initialData: Partial<EditProfileState>,
currentData: Partial<EditProfileState>
initialData: Partial<EditProfileState> | DataByRole<string>,
currentData: Partial<EditProfileState> | DataByRole<string>
): boolean => {
return JSON.stringify(initialData) !== JSON.stringify(currentData)
}
Expand Down Expand Up @@ -170,10 +170,7 @@ const EditProfile = () => {
photo: currentPhoto
}

if (
areAllValuesEmptyStrings(initialVideoLink) &&
areAllValuesEmptyStrings(currentVideoLink)
) {
if (!hasChanges(initialVideoLink, currentVideoLink)) {
delete changes.videoLink
}

Expand Down

0 comments on commit 6ea36f0

Please sign in to comment.