8000 Fix tag separators in the bookmarks CSV export by m86hussein · Pull Request #4059 · quran/quran_android · GitHub
[go: up one dir, main page]

Skip to content

Fix tag separators in the bookmarks CSV export - #4059

Open
m86hussein wants to merge 1 commit into
quran:mainfrom
m86hussein:fix/csv-export-tag-separator
Open

m86hussein wants to merge 1 commit into
quran:mainfrom
m86hussein:fix/csv-export-tag-separator

Conversation

@m86hussein
@m86hussein m86hussein commented Nov 22, 2026 •
Copy link
Copy Markdown
Contributor

Summary

Fixes the tags column of the bookmarks CSV export (#4058).

The bug

Bookmark.getSemiColonSeparatedTags used:

tags.map { tagsList.find { tag -> tag.id == it }?.name }
  .reduceOrNull { tags, tag -> "$tags$tag|" }

reduceOrNull uses the first name as the starting accumulator and appends tag| for each later name. So:

Tags Before After
[A] A A
[A, B] AB| A|B
[A, B, C] AB|C| A|B|C
none null (empty)
[unknown id, B] nullB| B

The fix

tags.mapNotNull { tagsList.find { tag -> tag.id == it }?.name }
  .joinToString("|")

An untagged bookmark now has an empty tags column, matching how recent and reading_bookmark rows already leave it empty.

Testing

  • Added testExportBookmarksCsvSeparatesMultipleTagsAndLeavesUntaggedEmpty to BookmarkImportExportModelTest. It covers three tags, no tags, and an unresolved tag id. It fails on main with FirstSecond|Third| / null / nullSecond|, and passes with this change.
  • ./gradlew :app:testMadaniDebugUnitTest --tests "*Bookmark*": all suites pass, except 5 tests that save the export to a file: testExportBookmarks*ProducesUri, *IncludesResolvedPage and *NumbersBookmarkIds*. Those fail identically on unmodified main on Windows: Robolectric's FileProvider doesn't find the configured root for a Windows path. They should pass on CI (Linux).

Fixes #4058

AI disclosure: this PR was drafted with GitHub Copilot and opened by @m86hussein, who is responsible for it.

The tags column was built with `reduceOrNull { acc, tag -> "$acc$tag|" }`,
which puts the separator after the second tag instead of between tags:
[A, B] became "AB|" and [A, B, C] became "AB|C|". Untagged bookmarks got
the literal "null", and tag ids without a matching tag were written as
"null" too.

Join the resolved tag names with "|" and skip unknown ids, so untagged
bookmarks get an empty tags column like the other row types.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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.

Bookmarks CSV export joins multiple tags incorrectly and writes null for untagged bookmarks

1 participant

0