Skip to content

fix: Manage note types add clone - #22584

Merged
criticalAY merged 1 commit into
ankidroid:mainfrom
criticalAY:managenotetypes-add-clone
Nov 3, 2026
Merged

criticalAY merged 1 commit into
ankidroid:mainfrom
criticalAY:managenotetypes-add-clone

Conversation

@criticalAY

Copy link
Copy Markdown
Contributor

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

Approach

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?

  • New ViewModel tests: adding a stock note type, cloning one, cloning a missing note type, and progress for both
  • A dialog test that adding from the dialog shows the new note type in the list (green before and after the move)

Learning (optional, can help others)

NA

Checklist

Please, go through these checks before submitting the PR.

  • You have a descriptive commit message with a short title (first line, max 50 chars).
  • You have commented your code, particularly in hard-to-understand areas
  • You have performed a self-review of your own code
  • UI changes: include screenshots of all affected screens (in particular showing any new or changed strings)
  • UI Changes: You have tested your change using the Google Accessibility Scanner

@criticalAY criticalAY added the Blocked by dependency Currently blocked by some other dependent / related change label Oct 17, 2026
@criticalAY criticalAY changed the title Managenotetypes add clone fix: Manage note types add clone Oct 17, 2026
@criticalAY
criticalAY force-pushed the managenotetypes-add-clone branch from 6dd7c14 to eb2975f Compare October 18, 2026 11:49
@criticalAY
criticalAY force-pushed the managenotetypes-add-clone branch from eb2975f to 8a7ca21 Compare October 21, 2026 03:02
@github-actions

github-actions Bot commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

Snapshot diff report: Previous regressions were resolved by the latest commit.

@criticalAY criticalAY removed the Blocked by dependency Currently blocked by some other dependent / related change label Oct 21, 2026

@mikehardy mikehardy left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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.

@mikehardy mikehardy added Needs Second Approval Has one approval, one more approval to merge and removed Needs Review labels Oct 22, 2026
david-allison

This comment was marked as resolved.

@david-allison david-allison added the Needs Author Reply Waiting for a reply from the original author label Oct 23, 2026
@criticalAY criticalAY removed the Needs Author Reply Waiting for a reply from the original author label Oct 26, 2026
@criticalAY

Copy link
Copy Markdown
Contributor Author

david-allison

This comment was marked as resolved.

@david-allison david-allison added the Needs Author Reply Waiting for a reply from the original author label Nov 2, 2026
@criticalAY
criticalAY force-pushed the managenotetypes-add-clone branch from 8a7ca21 to 536c1c8 Compare November 2, 2026 20:17
david-allison

This comment was marked as resolved.

@criticalAY
criticalAY force-pushed the managenotetypes-add-clone branch from 536c1c8 to afddcba Compare November 2, 2026 21:00
@criticalAY criticalAY removed the Needs Author Reply Waiting for a reply from the original author label Nov 2, 2026
david-allison

This comment was marked as resolved.

@david-allison david-allison added the Needs Author Reply Waiting for a reply from the original author label Nov 2, 2026
@criticalAY criticalAY removed the Needs Author Reply Waiting for a reply from the original author label Nov 2, 2026
@criticalAY
criticalAY force-pushed the managenotetypes-add-clone branch from afddcba to e406c3c Compare November 2, 2026 22:09

@david-allison david-allison left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM, few stylistic nits

enableToolbar()
binding.noteTypesList.adapter = notetypesAdapter
observeProgress(viewModel) { it }
viewModel.pendingAdd?.let { pendingAdd -> launchCatchingTask { pendingAdd.await() } }

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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()

@david-allison david-allison added Needs Author Reply Waiting for a reply from the original author and removed Needs Second Approval Has one approval, one more approval to merge labels Nov 2, 2026
@david-allison david-allison added the Pending Merge Things with approval that are waiting future merge (e.g. targets a future release, CI wait, etc) label Nov 2, 2026
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
@criticalAY
criticalAY force-pushed the managenotetypes-add-clone branch from e406c3c to 36f6f4a Compare November 3, 2026 05:14
@criticalAY criticalAY removed Needs Author Reply Waiting for a reply from the original author Has Conflicts labels Nov 3, 2026

@mikehardy mikehardy left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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.

@mikehardy mikehardy added the Needs Second Approval Has one approval, one more approval to merge label Nov 3, 2026
@criticalAY criticalAY removed the Needs Second Approval Has one approval, one more approval to merge label Nov 3, 2026
@criticalAY
criticalAY enabled auto-merge November 3, 2026 05:59
@criticalAY
criticalAY added this pull request to the merge queue Nov 3, 2026
Merged via the queue into ankidroid:main with commit 920e8c7 Nov 3, 2026
25 checks passed
@github-actions github-actions Bot removed the Pending Merge Things with approval that are waiting future merge (e.g. targets a future release, CI wait, etc) label Nov 3, 2026
@github-actions github-actions Bot added this to the 2.26 release milestone Nov 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants