feat(meshcore): pin favorited nodes to top of DM list (#3620)#3621
Conversation
MeshCore node favorites (#3588) pinned nodes to the top of the node list but had no effect on the Direct Messages contact list, which sorted purely by name or last-message time. This mirrors the Meshtastic DM list behavior for MeshCore. The favorite flag lives server-side on the node list, not on contacts (MeshCore firmware has no native favorite concept), so the DM view now receives the `nodes` list and builds a publicKey->isFavorite lookup. Favorited peers pin to the top regardless of the chosen sort field and direction, and show a read-only ★ indicator. The `nodes` prop is optional so legacy callers degrade gracefully (no pinning). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011JEaCGwY9Wz8jeV4e22GW4
|
Claude finished @Yeraze's task —— View job PR Review: feat(meshcore): pin favorited nodes to top of DM list
SummaryThis is a clean, well-scoped frontend-only change that addresses a legitimate UX gap. The implementation is consistent with patterns used elsewhere in the codebase. A few observations: Code Quality & Best Practices
Minor observation: The Potential BugsSearch + favorites interaction (line 209–217): The Favorites from One edge case to verify: The Performance
SecurityNo security concerns — this is purely a read-only UI sort/display change with no API calls, auth changes, or user-controlled data paths added. Test CoverageThe new test at line 261–290 (
Missing coverage: There's no test asserting that favorites remain pinned when the user switches to name sort (ascending or descending). The Also no test for the ★ indicator being absent when OverallApproved with minor suggestions. The implementation is correct, well-tested for the primary case, and consistent with codebase patterns. The only gap is a test for favorites-stay-pinned under name sort, which is low risk given the sort logic structure but would be a solid regression guard. |
Addresses the Claude Code Review suggestion: the `aFav !== bFav` pin runs ahead of both sort branches, so add a regression guard that favorites stay on top under name sort, not just the default lastMessage sort. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011JEaCGwY9Wz8jeV4e22GW4
|
Addressed the review suggestion in 17e1b63: added a regression test ( Left the asymmetric |
|
Claude finished @Yeraze's task —— View job PR Review: feat(meshcore): pin favorited nodes to top of DM list
SummaryThis is a clean, well-scoped follow-up that directly addresses the feedback from the prior review. The implementation remains sound, and the new regression test ( New test (17e1b63) —
|
Summary
Closes #3620.
MeshCore node favorites (#3588) pinned nodes to the top of the node list but had no effect on the Direct Messages contact list, which sorted only by name or last-message time — unlike Meshtastic, where favorites pin to the top of the DM list.
Root cause: The favorite flag lives server-side on the node list (MeshCore firmware has no native favorite concept), not on the contact records that feed the DM view.
MeshCoreDirectMessagesViewonly receivedcontacts, which carry noisFavorite, so the sort couldn't see it.Changes
Frontend-only — no backend/API/migration changes needed, since the
useMeshCorehook already maintains a reliably-reconcilednodeslist withisFavorite.MeshCorePage.tsx— pass the existingnodesarray to the DM view.MeshCoreDirectMessagesView.tsx— accept an optionalnodesprop, build apublicKey → isFavoritelookup, pin favorited peers to the top of the sort (regardless of sort field/direction, matching the Meshtastic DM list and the MeshCore node list), and render a read-only ★ next to favorited rows. Thenodesprop is optional so legacy callers degrade gracefully (no pinning).MeshCorePage.css— style the ★ indicator (.mc-dm-row-favorite).MeshCoreDirectMessagesView.test.tsx— new test asserting a favorited peer pins to the top despite oldest last-message time, plus the ★ indicator.Testing
MeshCoreDirectMessagesView.test.tsxpass (success: true).🤖 Generated with Claude Code