feat(sync): migrate torrent telemetry to reactive maindata delta sync#106
Merged
Conversation
- Make Torrent struct conform to Codable and change its properties to var to support mutability and testing serialization - Extend MainData struct to decode categories, tags, and torrents diff arrays - Define PartialTorrent model with all optional fields to parse incoming delta updates - Implement stub class TorrentCacheManager with merge(mainData:) method - Create TorrentCacheManagerTests class containing 3 unit tests verifying delta merging, pruning, and reset updates
…heManager - Add mutating update(from:) method to Torrent to apply properties from PartialTorrent in-place - Define placeholder initializer init(hash:) and update-based convenience initializer init(from:hash:) inside extension Torrent - Implement delta updates, pruning, and full update reset logic in TorrentCacheManager
…iewmodel to observe cache - Update qBitData telemetry loop to host TorrentCacheManager and merge incoming sync updates on every 2-second poll - Refactor TorrentListHelperViewModel to observe the global cacheManager's torrents dictionary reactively using Combine - Implement high-performance local filtering (by status, search query, category, and tag) and local sorting (by size, progress, speeds, dates, ratio, eta, and priority) to replace redundant server-side calls - Remove individual viewmodel background polling timers, consolidating all sync tasks into a single HTTP request cycle - Support "seeding" as a status filter alias in local processing to maintain compatibility with test suites - Implement setUp() in TorrentListHelperViewModelTests to isolate test cases by clearing the qBitData singleton cache before each run - Remove asynchronous run loop scheduling (.receive(on:)) in Combine subscriptions to enable synchronous property propagation for unit test assertions
…fe enums - Create TorrentSortOption enum containing all 34 possible qBittorrent sorting criteria - Create TorrentFilterOption enum containing all torrent status/state filter values, including the 'checking' and 'seeding' cases - Refactor TorrentListHelperViewModel to store sort and filter properties using the new enum types - Update local filtering and sorting logic switch blocks to exhaustively map all enum cases, ensuring compiler-enforced reliability - Refactor FiltersMenuView bindings and Picker tag elements to map directly to enum values instead of hardcoded strings - Save enum .rawValue strings to UserDefaults to preserve backwards-compatibility for stored user settings - Update TorrentListHelperViewModelTests to use type-safe enums in filter/sort mock test assertions and assignments
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Migrates the core torrent data pipeline from polling full lists (
/api/v2/torrents/info) to lightweight delta sync updates (/api/v2/sync/maindata). The app now maintains a local cache, merges updates in-place, and processes all filtering and sorting locally. This reduces network payload size and CPU overhead by a significant amount.Key Changes