8000 Allow removing tags from multiple bookmarks by nabeeltahirdeveloper · Pull Request #3919 · quran/quran_android · GitHub
[go: up one dir, main page]

Skip to content

Allow removing tags from multiple bookmarks - #3919

Open
nabeeltahirdeveloper wants to merge 1 commit into
quran:mainfrom
nabeeltahirdeveloper:fix/2208-multi-bookmark-untag
Open

nabeeltahirdeveloper wants to merge 1 commit into
quran:mainfrom
nabeeltahirdeveloper:fix/2208-multi-bookmark-untag

Conversation

@nabeeltahirdeveloper
Copy link
Copy Markdown

Fixes #2208

Tags could be added to multiple selected ayat at once, but never removed: when more than one bookmark was selected, TagBookmarkPresenter loaded no checked tags at all (its tag-ids observable returned an empty list for multiple ids), and saving called updateBookmarkTags with deleteNonTagged = false, which only ever adds tags.

This change makes multi-selection behave like a bulk version of the single-bookmark dialog:

  • The tag ids of all selected bookmarks are loaded and intersected, so the tags that every selected bookmark shares start out checked. Tags that only some bookmarks have start out unchecked, exactly as a tag that no bookmark has does.
  • The initially checked (common) tags are remembered. On save, any common tag that was unchecked is removed from every selected bookmark via the existing removeBookmarkFromTag, and the checked tags are then added to all of them via the existing additive updateBookmarkTags call.
  • Tags that only some of the bookmarks have are in neither the removed set nor required to be checked, so saving never removes them — adding a tag to a mixed selection keeps working exactly as before.
  • Single-bookmark behaviour is unchanged (full replace via deleteNonTagged = true).

Tests: four new cases in TagBookmarkPresenterTest covering the common-tag checked state, removing a common tag from all bookmarks, keeping tags that only one bookmark has when a common tag is removed, and adding a tag to multiple bookmarks without removing existing ones.

Testing note: I was unable to run the Gradle test suite in my environment (the Gradle daemon cannot start there — it fails with "Could not dispatch/receive a message from the daemon" before any compilation happens, on unmodified code as well). I verified the change by compiling the touched production and test files standalone with kotlinc (only the expected unresolved-reference errors from the missing classpath, identical in kind to the unmodified files), and by running an assertion harness that ports the presenter's new load/toggle/save logic together with the fake DAO's semantics: all new unit-test assertions pass against the new logic (17/17 checks including the pre-existing single-bookmark scenarios), and the removal assertions fail against the old logic. Happy to adjust if CI or a maintainer run shows anything I couldn't.

When several bookmarks were selected, TagBookmarkPresenter loaded no
checked tags at all and saved with deleteNonTagged = false, which only
ever adds tags - so a tag could be added to multiple ayat but never
removed from them (quran#2208).

Load the tags that all selected bookmarks share (their intersection)
as the checked set, remember them as the common tags, and on save
remove any common tag that was unchecked from every bookmark via
removeBookmarkFromTag before adding the checked tags as before. Tags
that only some of the selected bookmarks have are in neither set, so
saving never removes them. Single-bookmark behaviour is unchanged.

Adds TagBookmarkPresenterTest cases for the common-tag checked state,
removing a common tag from all bookmarks, keeping partial tags, and
adding a tag to multiple bookmarks.
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.

Can not remove tags for multiple Ayat

1 participant

0