Skip to content
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

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

arnolicious
Copy link
Contributor

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.

Copy link
Member

@danieldietzler danieldietzler left a 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? :)

server/src/dtos/person.dto.ts Outdated Show resolved Hide resolved
server/src/repositories/person.repository.ts Show resolved Hide resolved
if (person.id === updatedPerson.id) {
return updatedPerson;
}
return person;
Copy link
Member

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?

Copy link
Contributor Author

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

Copy link
Member

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)

Copy link
Contributor Author

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 👍

@arnolicious
Copy link
Contributor Author

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

Copy link
Member

@danieldietzler danieldietzler left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants