fix(store): keep new contacts in the sorted index - #5708
Conversation
Assisted-by: ClaudeCode:claude-opus-5 Signed-off-by: Hamza <hamzamahjoubi221@gmail.com>
|
@coderabbitai review |
✅ Action performedReview finished.
|
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Team Run ID: 📒 Files selected for processing (2)
Included review availability: Your plan provides up to 4 included reviews per hour; 3 remain after this review. 📝 WalkthroughWalkthroughThe contacts store now uses shared sorting helpers that preserve contact value types and prioritize favorites. Contact insertion, updates, replacement, and bulk sorting use the revised representation. New tests cover ordering, favorites, middle insertion, and a 300-contact regression case. ChangesContact sorting consistency
Estimated code review effort: 3 (Moderate) | ~20 minutes Merge Risk: ⚪ Minimal · up to New contacts are retained in the sorted contact index, allowing the creation form to open instead of showing “Contact not found.” The updated sorting behavior is covered across relevant insertion and ordering scenarios, with no remaining merge-blocking risk. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
🧪 Generate unit tests (beta)
Warning Some tools did not complete. Review the errors below. 🔧 ESLint
tests/javascript/store/contactsMutations.test.jsOops! Something went wrong! :( ESLint: 10.10.0 ReferenceError: module is not defined in ES module scope Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
|
/backport to stable8.8 |
|
Claude found this: The old insertion loop had its condition inverted (sortData(other, sortedContact) >= 0 → continue), so it inserted before the first contact that sorts earlier, and dropped the contact entirely when every existing contact sorted after it. Confirmed in the live store on the parent commit and fixed by the PR:
(Contacts fetched from the server come back as vCard 3.0, where N components stay strings — that's why normal browsing doesn't hit it.)
Worth noting on the plus side: the PR removes a real pre-existing inconsistency — sortContacts built values without .toLowerCase() while setContacts/addContact applied it, so the index held mixed-case entries after a sort-order change. |
Fix #5681
Assisted-by: ClaudeCode:claude-opus-5
🤖 AI (if applicable)
Summary by CodeRabbit
Bug Fixes
Tests