From 46034aff54c35497f48cf7831fafb626d1456200 Mon Sep 17 00:00:00 2001 From: Jason Dove <1695733+jasongdove@users.noreply.github.com> Date: Sat, 25 Mar 2023 05:58:41 -0500 Subject: [PATCH] fix updating trakt lists (#1218) --- CHANGELOG.md | 2 ++ .../MediaCollections/Commands/AddTraktListHandler.cs | 2 +- .../MediaCollections/Commands/TraktCommandBase.cs | 6 +++++- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f15f1b7c..4bdc5cff 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,8 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ## [Unreleased] +### Fixed +- Fix updating (re-adding) Trakt lists to properly use new metadata ids that were not present when originally added ## [0.7.6-beta] - 2023-03-24 ### Added diff --git a/ErsatzTV.Application/MediaCollections/Commands/AddTraktListHandler.cs b/ErsatzTV.Application/MediaCollections/Commands/AddTraktListHandler.cs index 3d71e2d7..ff010785 100644 --- a/ErsatzTV.Application/MediaCollections/Commands/AddTraktListHandler.cs +++ b/ErsatzTV.Application/MediaCollections/Commands/AddTraktListHandler.cs @@ -61,7 +61,7 @@ public class AddTraktListHandler : TraktCommandBase, IRequestHandler> DoAdd(Parameters parameters) { - await using TvContext dbContext = _dbContextFactory.CreateDbContext(); + await using TvContext dbContext = await _dbContextFactory.CreateDbContextAsync(); return await TraktApiClient.GetUserList(parameters.User, parameters.List) .BindT(list => SaveList(dbContext, list)) diff --git a/ErsatzTV.Application/MediaCollections/Commands/TraktCommandBase.cs b/ErsatzTV.Application/MediaCollections/Commands/TraktCommandBase.cs index ed309621..d4634298 100644 --- a/ErsatzTV.Application/MediaCollections/Commands/TraktCommandBase.cs +++ b/ErsatzTV.Application/MediaCollections/Commands/TraktCommandBase.cs @@ -87,7 +87,11 @@ public abstract class TraktCommandBase foreach (TraktListItem existing in toUpdate) { - Option maybeIncoming = list.Items.Find(i => i.TraktId == existing.TraktId); + Option maybeIncoming = items + .Filter(i => i.TraktId == existing.TraktId) + .Map(i => ProjectItem(list, i)) + .HeadOrNone(); + foreach (TraktListItem incoming in maybeIncoming) { existing.Kind = incoming.Kind;