-
Notifications
You must be signed in to change notification settings - Fork 16
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
Prevent profile updates without changes #2849
Merged
luiqor
merged 18 commits into
develop
from
bugfix/2807/disallow-update-profile-without-changes
Nov 30, 2024
Merged
Changes from 17 commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
2d0d580
fix videoLink type in edit profile slice
luiqor d9f1ae5
fix photo and videoLink edit processing by role
luiqor 2e99338
update editProfileSlice tests
luiqor ca0f056
fix sending videoLink as empty string to server
luiqor bea0d26
fix updating videoLink as empty string is not send to server
luiqor c32525b
fix tests to include actual initial videoLink state
luiqor fc7e53e
fix photo change on edit profile page
luiqor b0694e3
fix edit profile tests
luiqor f809939
add EditProfilePhoto type
luiqor b728ed6
fix avatarSrc in AccountIcon type check
luiqor 6ea36f0
fix sending unchnaged videoLink every time to server
luiqor 3bcd35c
fix removed photo display in account icon
luiqor 8c242ef
add fetching user data from server on page unload to prevent showing …
luiqor b6830b2
add tests for EditProfile
luiqor 7ce0a96
extract utils and add tests
luiqor 913c74b
extract hasPhotoChanges util and add tests
luiqor d5fecd6
improve has photo changes test to inlcude mocked functions
luiqor 79f0e84
remove void for dispatch in debouncedUpdateProfileData
luiqor File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
export const areAllValuesEmptyStrings = (obj: { | ||
[key: string]: string | ||
}): boolean => { | ||
return Object.values(obj).every( | ||
(value) => typeof value === 'string' && value === '' | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import { EditProfilePhoto, UpdatedPhoto } from '~/types' | ||
import { isUpdatedPhoto } from '~/utils/is-updated-photo' | ||
import { areAllValuesEmptyStrings } from '~/utils/are-all-values-empty-strings' | ||
|
||
export const hasPhotoChanges = ( | ||
initialPhoto: EditProfilePhoto, | ||
currentPhoto: EditProfilePhoto | ||
): boolean => { | ||
if (initialPhoto !== '' && currentPhoto === '') { | ||
return true | ||
} | ||
|
||
if ( | ||
typeof initialPhoto === 'string' && | ||
isUpdatedPhoto(currentPhoto) && | ||
(currentPhoto as UpdatedPhoto).name !== initialPhoto | ||
) { | ||
return true | ||
} | ||
|
||
if ( | ||
initialPhoto === null && | ||
isUpdatedPhoto(currentPhoto) && | ||
areAllValuesEmptyStrings(currentPhoto as UpdatedPhoto) | ||
) { | ||
return true | ||
} | ||
|
||
if ( | ||
isUpdatedPhoto(initialPhoto) && | ||
isUpdatedPhoto(currentPhoto) && | ||
(initialPhoto as UpdatedPhoto).name !== (currentPhoto as UpdatedPhoto).name | ||
) { | ||
return true | ||
} | ||
|
||
return false | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { EditProfilePhoto } from '~/types' | ||
|
||
export const isUpdatedPhoto = (photo: EditProfilePhoto): boolean => { | ||
return ( | ||
photo !== null && | ||
typeof photo === 'object' && | ||
'name' in photo && | ||
'src' in photo | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider removing the
void
operator for better maintainability.Link
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Resolved ✅