-
-
Notifications
You must be signed in to change notification settings - Fork 3k
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
feat: Mark people as favorite #14866
base: main
Are you sure you want to change the base?
Conversation
…he front of the people list
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.
The code looks very good to me, thanks! Could you add a simple server unit test for it? :)
if (person.id === updatedPerson.id) { | ||
return updatedPerson; | ||
} | ||
return person; |
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.
When can you possibly not find your person in here?
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.
Not exactly sure what you mean, this is inside of the map, its replacing the updatedPerson inside of the person list.
And I just copied the code for the other handlers in that file :D
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.
What I had in mind is that const index = findIndex((person) => person.id === detail.id)
followed by people[index] = updatedPerson
should also work and is imo more intuitive to read. (plus it should be a touch more efficient lol)
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.
Ahh right, I refactored it like that now 👍
I added a simple unit test for testing the toggling, I also tried adding a test to check the sorting behaviour, tho I have not ran it locally and it was mostly guessing that this could work :D @danieldietzler |
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.
The code LGTM
Added the ability to mark people as favorite on web.
The
GET /people
Endpoint then sorts favorited people to the front of the list.Thus the sorting would also apply in the app, however I have not (yet) added any indicators or functionality to mark people as favorite from there.