Commit 7fffc44
fix(settings): resolve category drag-and-drop snapping back to original position
Three chained bugs caused dragged categories to snap back immediately on
release, with no order persisted across screen reopens.
Bug 1 — LaunchedEffect fired at the wrong moment (SettingsScreen.kt):
isDragging was listed as a LaunchedEffect key, so releasing the drag
triggered the effect immediately. At that point categories still held
the stale order (DataStore hadn't responded yet), resetting orderedCategories
to the old list and producing the visible snap-back on every drag release.
Fix: remove isDragging from the key list; keep it only as an internal guard.
Bug 2 — reorderFromIds() was a silent no-op (CategoryRepository.kt):
The method body was empty — left as a stub. SettingsViewModel wrapped it
in a db.withTransaction that wrote nothing, so DataStore was never updated
and the custom order was lost on any recomposition.
Fix: call preferences.setCategoryOrder(orderedIds) directly in
updateCategoryOrder(), removing the pointless db transaction wrapper.
Bug 3 — SettingsViewModel.categories ignored DataStore order (SettingsViewModel.kt):
The categories StateFlow was built from observeAll() alone (Room ORDER BY
nombre ASC), always returning alphabetical order regardless of any saved
custom order. VaultViewModel already had the correct pattern but it was
never replicated here.
Fix: mirror VaultViewModel — combine(observeAll, categoryOrderFlow) and
apply applyCategoryOrder() to respect the persisted DataStore order.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>1 parent 8021fbb commit 7fffc44
2 files changed
Lines changed: 10 additions & 6 deletions
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
123 | 123 | | |
124 | 124 | | |
125 | 125 | | |
126 | | - | |
| 126 | + | |
127 | 127 | | |
128 | 128 | | |
129 | 129 | | |
| |||
Lines changed: 9 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
| 23 | + | |
23 | 24 | | |
24 | 25 | | |
| 26 | + | |
25 | 27 | | |
26 | 28 | | |
27 | 29 | | |
| |||
51 | 53 | | |
52 | 54 | | |
53 | 55 | | |
54 | | - | |
55 | | - | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
56 | 62 | | |
57 | 63 | | |
58 | 64 | | |
| |||
300 | 306 | | |
301 | 307 | | |
302 | 308 | | |
303 | | - | |
304 | | - | |
305 | | - | |
| 309 | + | |
306 | 310 | | |
307 | 311 | | |
308 | 312 | | |
| |||
0 commit comments