profile edit: fix genres select edge case on when the user does not already have selected any genres

This commit is contained in:
Nuwan 2024-09-21 09:38:26 +05:30
parent c779277b4d
commit 9a0b4f4ddb
1 changed files with 3 additions and 1 deletions

View File

@ -150,7 +150,7 @@ function JKEditProfile() {
};
useEffect(() => {
if (genreInitialLoadingDone || genres.length === 0 || userGenres.length === 0) return;
if (genreInitialLoadingDone || genres.length === 0) return;
const updatedGenres = genres.map(genre => {
const userGenre = userGenres.find(userGenre => userGenre.genre_id === genre.id);
@ -269,6 +269,7 @@ function JKEditProfile() {
};
const handleGenreChange = (e, genre) => {
if (e.target.checked) {
const userGenres = getValues('genres');
const thisGenre = userGenres.find(userGenre => userGenre.genre_id === genre.genre_id);
@ -281,6 +282,7 @@ function JKEditProfile() {
}
const updatedGenres = genres.map(genreItem => {
console.log('genreItem', genreItem, genre);
if (genreItem.genre_id === genre.genre_id) {
genreItem.checked = e.target.checked;
} else {