Skip to content

Claude/fix tags implementation 011 cu mq cz hj hc j14dnk rcury#8

Merged
oyvindbso merged 4 commits intomainfrom
claude/fix-tags-implementation-011CUMqCzHJHcJ14dnkRCURY
Oct 22, 2025
Merged

Claude/fix tags implementation 011 cu mq cz hj hc j14dnk rcury#8
oyvindbso merged 4 commits intomainfrom
claude/fix-tags-implementation-011CUMqCzHJHcJ14dnkRCURY

Conversation

@oyvindbso
Copy link
Copy Markdown
Owner

Functioning tags

The tags feature was not working correctly because the caching layer
doesn't support tag filtering. This caused tag-filtered tabs to show
incorrect cached data that didn't match the tag filter.

Changes:
- Tag-filtered tabs now skip cache and always fetch from API
- Removed complex diagnostic system that was causing confusion
- Simplified error handling with clearer, more helpful messages
- Improved empty state messages for tag-filtered tabs
- Tag-filtered tabs now require internet connection (no offline mode)

The API integration for tags was already correct - the issue was
purely in how cached data was being loaded for tag-filtered tabs.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
…ameters

The issue was that Retrofit's @query with List<String> wasn't properly
expanding tags into multiple query parameters as required by the Zotero API.

Changes:
- Removed @query("tag") List<String> approach from Retrofit interface
- Added getItemsWithDynamicUrl method that accepts full URLs
- Manually build URLs with proper tag parameters: &tag=fiction&tag=sci-fi
- Added comprehensive logging to track:
  * Parsed tag list
  * Complete URL being called
  * Items received before filtering
  * Items after user preference filtering
- Properly URL-encode tag values to handle spaces and special characters

This ensures tags are sent correctly to the Zotero API in the format it expects:
/items?format=json&itemType=attachment&tag=fiction&tag=sci-fi

The logs will now clearly show if items are being returned by the API but
filtered out by user preferences (EPUB/PDF/books-only settings).

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
THE ROOT CAUSE: Tags in Zotero are assigned to parent items (books,
articles, etc.), NOT to attachment files (EPUBs/PDFs). The previous
implementation was searching for attachments with tags, which would
always return zero results.

Changes:
1. Removed itemType=attachment filter when searching with tags
   - Now searches ALL items with specified tags
   - The filterItemsByUserPreferences() method then filters to
     attachments (EPUB/PDF files)

2. Added extensive debug logging:
   - CollectionFragment logs all settings and received items
   - parseTagsToList logs each step of tag parsing
   - Shows toast message with tags being searched
   - Logs items before and after filtering

3. The correct flow is now:
   - Search: /items?tag=fiction&tag=sci-fi (all items with tags)
   - Results: Parent items (books/articles) that have those tags
   - Filter: Extract child attachments (EPUB/PDF) from results
   - Display: Show the filtered EPUB/PDF files

This matches how Zotero's data model works:
- Parent item (book/article) has metadata and tags
- Child items (attachments) are the actual files
- Tags are inherited conceptually but stored on parent

Please check logcat with filter "ZoteroApiClient" or "CollectionFragment"
to see detailed debugging information about what's being fetched.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
…ents

PREVIOUS IMPLEMENTATION WAS WRONG: The last fix searched for all items
with tags but then filtered by mimeType. This failed because parent items
(books, articles) don't have mimeTypes - only attachment children do.

THE CORRECT APPROACH (now implemented):

1. Search for parent items (books/articles) with tags:
   GET /users/{id}/items/top?tag=fiction&tag=sci-fi

2. For each parent item found, get its child attachments:
   GET /users/{id}/items/{parentKey}/children

3. Filter children to EPUB/PDF attachments only

4. Set parent reference on each attachment for metadata display

Implementation details:

- getAllEbookItemsWithTagFilter(): Entry point for tag filtering
- getParentItemsWithTags(): Step 1 - get parent items with tags
  Uses /items/top endpoint to get only top-level items (not children)
- getAttachmentsForParentItems(): Step 2 - iterate through parents
- getChildAttachments(): Fetches children for a single parent
- Comprehensive logging at each step for debugging
- Proper error handling - continues if one parent fails
- Thread-safe accumulation of results

This matches Zotero's data model:
- Parent item (book/article): has tags, title, authors
- Child items (attachments): has files, mimeType, download links
- Tags are ONLY on parent items, never on attachments

Why the previous approach failed:
- Searching itemType=attachment&tag=X returns nothing (attachments don't have tags)
- Searching just tag=X returns parents, which don't have mimeTypes
- Must do parent search → child lookup → filter pattern

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@oyvindbso oyvindbso merged commit a467682 into main Oct 22, 2025
1 check passed
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.

2 participants