Skip to content

feat: sort favorite contact first in list#5251

Open
GretaD wants to merge 4 commits intomainfrom
feat/sort-favorite-contacts
Open

feat: sort favorite contact first in list#5251
GretaD wants to merge 4 commits intomainfrom
feat/sort-favorite-contacts

Conversation

@GretaD
Copy link
Copy Markdown
Contributor

@GretaD GretaD commented Apr 10, 2026

Fixes #105

Screenshot from 2026-04-22 11-25-30

How to test

You need to link cdav-library with contacts while in this pr: nextcloud/cdav-library#1029

@GretaD GretaD self-assigned this Apr 10, 2026
@GretaD GretaD added enhancement New feature or request 2. developing Work in progress labels Apr 10, 2026
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 10, 2026

Codecov Report

❌ Patch coverage is 0% with 101 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/store/contacts.js 0.00% 46 Missing and 22 partials ⚠️
src/components/ContactsList/ContactsListItem.vue 0.00% 26 Missing ⚠️
src/models/contact.js 0.00% 4 Missing and 3 partials ⚠️

📢 Thoughts on this report? Let us know!

@GretaD

This comment was marked as outdated.

Signed-off-by: greta <gretadoci@gmail.com>
@GretaD GretaD force-pushed the feat/sort-favorite-contacts branch from 658fb4b to 693cb61 Compare May 4, 2026 09:23
@GretaD GretaD marked this pull request as ready for review May 4, 2026 09:25
@GretaD GretaD requested review from GVodyanov and hamza221 as code owners May 4, 2026 09:25
@GretaD GretaD added 3. to review Waiting for reviews and removed 2. developing Work in progress labels May 4, 2026
@DerDreschner DerDreschner self-requested a review May 4, 2026 10:03
Comment thread src/store/contacts.js Outdated
Comment thread src/store/contacts.js Outdated
Comment thread src/components/ContactsList/ContactsListItem.vue Outdated
Comment thread src/store/contacts.js
@ChristophWurst
Copy link
Copy Markdown
Member

Cleaned-up the PR description so it's clear that we can not merge this before the cdav merge, release and update here

Signed-off-by: greta <gretadoci@gmail.com>
Comment thread src/components/ContactsList/ContactsListItem.vue Outdated
Comment thread src/components/ContactsList/ContactsListItem.vue Outdated
Comment thread src/components/ContactsList/ContactsListItem.vue Outdated
Comment thread src/components/ContactsList/ContactsListItem.vue Outdated
Copy link
Copy Markdown
Contributor

@GVodyanov GVodyanov left a comment

Choose a reason for hiding this comment

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

Tested it and works great!

Just a few styling comments, will approve to not block.

I also noted that there is the age old issue representing itself (at least to me in firefox)

Image

Right after favouriting u get the star stuck on the side of the component until you hover over it, but that's almost more of a vue or browser bug probably, I had this on other PRs too and wasn't able to fix it.

Copy link
Copy Markdown
Contributor

@DerDreschner DerDreschner left a comment

Choose a reason for hiding this comment

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

For me, the sorting is... strange?

simplescreenrecorder-2026-05-06_15.14.52.mp4

And when I open a contact, the favorite status is being lost as it's only included in the PROPFIND for the address book by the cdav-library right now, not the contact itself. Could you have a look?

If necessary, I can modify the cdav-library to retrieve the favorite property as well. But as there is no star indicator on the contact itself, only the contacts list, I see no reason for retrieving it there as well.

Signed-off-by: greta <gretadoci@gmail.com>
@GretaD GretaD requested a review from DerDreschner May 7, 2026 12:37
Copy link
Copy Markdown
Contributor

@DerDreschner DerDreschner left a comment

Choose a reason for hiding this comment

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

Retested and the sorting is now correct! 😄 Only two things that can be fixed in follow-ups:

  • When selecting a contact marked as favorite, the contact list jumps unexpectedly so the selected contact is on the top for some reason:
simplescreenrecorder-2026-05-07_14.55.00.mp4

try {
await this.$store.dispatch('toggleFavorite', contact)
} catch (error) {
console.error('Could not toggle favorite state', error)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Should have user feedback too, showError

return
}
if (!contact.dav) {
console.error('Missing DAV object for contact', contact.key)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

use logger instead of console

Comment thread src/store/contacts.js Outdated
*/
async toggleFavorite(context, contact) {
if (!contact.dav) {
console.error('Missing DAV object for contact', contact.key)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Maybe throw exceptions instead, so the user is aware

Comment thread src/store/contacts.js Outdated
Comment on lines +394 to +395
context.commit('updateContactFavorite', contact)
await contact.dav.updateProperties()
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

These 2 have to be flipped, so the star is not added when the change is not saved

Copy link
Copy Markdown
Contributor

@hamza221 hamza221 left a comment

Choose a reason for hiding this comment

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

Image IMO the button shouldn't show for readonly contacts

@ChristophWurst
Copy link
Copy Markdown
Member

Read-only is fine. We want the feature to be usable for the SAB and for read-only shared ABs. It should only not be usable for the recently contacted, because that data is volatile.

Comment thread src/store/contacts.js Outdated
Comment thread src/store/contacts.js Outdated
Comment thread src/store/contacts.js Outdated
@hamza221
Copy link
Copy Markdown
Contributor

hamza221 commented May 7, 2026

Read-only is fine. We want the feature to be usable for the SAB and for read-only shared ABs. It should only not be usable for the recently contacted, because that data is volatile.

So it's supposed to work for SAB cards ?
I'll test again cause it didn't work when testing

Signed-off-by: greta <gretadoci@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

3. to review Waiting for reviews enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Sort favorite contacts first in list

5 participants