Reconcile Simkl watchlist one-directionally (remote wins)

Simkl's sync/all-items endpoint has no "added to list" timestamp
(last_watched_at is watch-history, not list-membership, and is null
for plantowatch items) so a real timestamp merge like Trakt's isn't
possible without risking local removals being silently undone by a
fabricated timestamp. Per explicit decision: items on Simkl's
plantowatch list are treated as authoritative and always restored
locally each sync, overriding any local removal tombstone. Removing
something from Simkl's own list doesn't remove it locally -- that
would need a persisted prior-snapshot to detect, out of scope here.
This commit is contained in:
KhooLy 2026-07-18 19:58:06 +03:00
parent 871bd2dcb7
commit 2339bfdc3c

View file

@ -119,6 +119,13 @@ internal class HomeLibraryCoordinator(
.onFailure { Log.w("HomeLibrary", "Trakt watched reconcile failed", it) }
}
}
if (profile != null && !simklToken.isNullOrBlank()) {
scope.launch(Dispatchers.IO) {
val remotePlanned = simklPlanned?.await().orEmpty()
runCatching { remotePlanned.forEach { watchlistManager.applyRemoteWatchlistAdd(it) } }
.onFailure { Log.w("HomeLibrary", "Simkl watchlist reconcile failed", it) }
}
}
} catch (e: Exception) {
Log.w("HomeLibrary", "Failed to load library data", e)
setLibraryState(_state.value.copy(