Repository navigation
fix: Manage note types add clone - #22584
Conversation
6dd7c14 to
eb2975f
Compare
eb2975f to
8a7ca21
Compare
|
Snapshot diff report: Previous regressions were resolved by the latest commit. |
mikehardy
left a comment
There was a problem hiding this comment.
Assisted-by: grok-4.7-medium
Thanks for moving add/clone into the ViewModel — centralizing progress and errors should make this screen much easier to follow.
Checked out the PR branch, rebased cleanly onto current ankidroid/main, and did not push (reviewed GitHub head 8a7ca21690d80c057b00090f1b0c0dfb2c377e05). Locally ran buildSrc tests, lintAll / ktlintCheck / lint-rules:test, jacocoUnitTestReport, and release emulator tests on API 36 Google APIs Play 16K (emulator-5554); all green on the rebased replay.
Add and clone now run through ManageNoteTypesViewModel with a single progress dialog, and failures surface on the same error state as delete. New unit tests cover the ViewModel path.
Screenshot changes have been detected, so leaving this for a good manual look.
|
8a7ca21 to
536c1c8
Compare
536c1c8 to
afddcba
Compare
afddcba to
e406c3c
Compare
david-allison
left a comment
There was a problem hiding this comment.
LGTM, few stylistic nits
| enableToolbar() | ||
| binding.noteTypesList.adapter = notetypesAdapter | ||
| observeProgress(viewModel) { it } | ||
| viewModel.pendingAdd?.let { pendingAdd -> launchCatchingTask { pendingAdd.await() } } |
There was a problem hiding this comment.
extension method please. The intent isn't immediately clear
context(activity: FragmentActivity)
fun Deferred<*>.awaitCatchingTask(): Job =
activity.launchCatchingTask { await() }
// Then, inside ManageNotetypes:
viewModel.pendingAdd?.awaitCatchingTask()Adding or cloning a note type ran its collection work inside the dialog. It now runs in ManageNoteTypesViewModel, which adds the note type and reloads the list under one progress dialog, even if the screen is recreated meanwhile. Errors still go through launchCatchingTask, also on a recreated screen. Assisted-by: Claude Opus 5.5
e406c3c to
36f6f4a
Compare
mikehardy
left a comment
There was a problem hiding this comment.
Assisted-by: Grok 4.7
Thank you — the dialog no longer owns the collection write, and the recreation tests cover both a successful add and the validation and corruption failures David asked for.
Checked out the PR branch for a clean replay at 36f6f4af; did not push. Locally ran lint, unit tests, and release emulator tests on emulator-5556 (API35_GAPI); all passed.
Add and clone now run in ManageNoteTypesViewModel under one progress op: the dialog validates the name and calls addStockNoteType or cloneNoteType, which withProgress the collection write and reload the list; pendingAdd lets a recreated activity re-await the same Deferred via awaitCatchingTask, so in-flight failures still reach launchCatchingTask for validation or corruption dialogs. Unit and Robolectric tests cover the ViewModel path, dialog wiring, error handling, and recreation for success and failure.
some acceptable findings, no action required, just leaving for posterity: the commit subject is a 70-character refactor: though behavior includes progress plus error reattachment; pendingAdd clears when the async completes, not when the new activity has shown an error (tests hold the dispatcher across the recreation gap).
Merge pending CI on a few GitHub jobs; local lanes were green on the replayed tip.
Note
Assisted-by: opus 5.5
Purpose / Description
Adding or cloning a note type still ran its collection work inside the dialog. This moves both into
ManageNoteTypesViewModel, next to rename and delete.Fixes
withProgressin ViewModels #19460Approach
See commit. Add and clone now reload the list under the same progress dialog, and failures go through the screen's error state like the other operations.
How Has This Been Tested?
Learning (optional, can help others)
NA
Checklist
Please, go through these checks before submitting the PR.