Anki-Android icon indicating copy to clipboard operation
Anki-Android copied to clipboard

Fix missing minus symbol when updating tags in card browser

Open thedroiddiv opened this issue 1 month ago • 2 comments

Purpose / Description

Fix missing minus symbol when selecting several cards at once in the card browser to update tags.

Fixes

  • Fixes #19083

Approach

Problem

This happened because the previous implementation

  • treated all notes present in any note as "checked"
  • remaining all were marked as "unchecked

Expected

  • tags present in all notes : "checked"
  • tags present in some, but not all notes: "indeterminate"
  • tags present in none of the notes: unchecked

Fix

  • check all notes, check if each tag is present or absent
  • add to checked list if present else add to unchecked list
  • this operations might result in few tags being present in both lists
  • intersecting tags are the "indeterminate" ones which are correctly captured by [TagsList]
  • tags coming from intent's extras are treated as absolute checked and cannot be indeterminate

How Has This Been Tested?

Added unit test for "indeterminate" Existing tests pass Manually Tested

image image image image

Checklist

  • [x] You have a descriptive commit message with a short title (first line, max 50 chars).
  • [x] You have commented your code, particularly in hard-to-understand areas
  • [x] You have performed a self-review of your own code
  • [x] 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

thedroiddiv avatar Nov 16 '25 19:11 thedroiddiv

Also, the tests assume NoteList works as expected, any error in NoteList will result in ViewModelTest to fail, even though actual issue might not be in the ViewModel.

thedroiddiv avatar Nov 16 '25 19:11 thedroiddiv

As a request: could the conclusion of this be moved into the class/argument documentation:

It's there as a test, will include in docs too.

Todos before next approval:

  • [x] Add the conclusion to docs 19499#discussion_r2532184695
  • [x] Replace if-else partitioning with Array::partition
  • [ ] ~Lift up db call out of loop~
  • [x] Add a todo for "Lift up db call out of loop"

thedroiddiv avatar Nov 28 '25 08:11 thedroiddiv

@david-allison per discussion on discord, queue for release-2.23 pick or not? I think we decided not - but perhaps later after alpha testing verifies it's working?

mikehardy avatar Dec 15 '25 13:12 mikehardy

As discussed, a little too much risk. My mistake last year with tags still haunts me.

Let's aim for a fairly quick 2.24 with this in

david-allison avatar Dec 15 '25 13:12 david-allison