Skip to content

Commit

Permalink
fix: reset cached titles when adding/removing tmdb links
Browse files Browse the repository at this point in the history
  • Loading branch information
revam committed Sep 22, 2024
1 parent 11b0b34 commit 079f80b
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions Shoko.Server/API/v3/Controllers/SeriesController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ public class SeriesController : BaseController
{
private readonly AnimeSeriesService _seriesService;

private readonly AnimeGroupService _groupService;

private readonly AniDBTitleHelper _titleHelper;

private readonly ISchedulerFactory _schedulerFactory;
Expand All @@ -77,6 +79,7 @@ public class SeriesController : BaseController
public SeriesController(
ISettingsProvider settingsProvider,
AnimeSeriesService seriesService,
AnimeGroupService groupService,
AniDBTitleHelper titleHelper,
ISchedulerFactory schedulerFactory,
TmdbLinkingService tmdbLinkingService,
Expand All @@ -87,6 +90,7 @@ WatchedStatusService watchedService
) : base(settingsProvider)
{
_seriesService = seriesService;
_groupService = groupService;
_titleHelper = titleHelper;
_schedulerFactory = schedulerFactory;
_tmdbLinkingService = tmdbLinkingService;
Expand Down Expand Up @@ -1444,6 +1448,12 @@ public async Task<ActionResult> AddLinkToTMDBShowsBySeriesID(
if (needRefresh)
await _tmdbMetadataService.ScheduleUpdateOfShow(body.ID, forceRefresh: body.Refresh, downloadImages: true);

// Reset series/group titles/descriptions when a new link is added.
series.ResetAnimeTitles();
series.ResetPreferredTitle();
series.ResetPreferredOverview();
_groupService.UpdateStatsFromTopLevel(series?.AnimeGroup?.TopLevelAnimeGroup, false, false);

return NoContent();
}

Expand Down Expand Up @@ -1472,6 +1482,13 @@ public async Task<ActionResult> RemoveLinkToTMDBShowsBySeriesID(
else
await _tmdbLinkingService.RemoveAllShowLinksForAnime(series.AniDB_ID, body?.Purge ?? false);

// Reset series/group titles/descriptions when a link is removed.
series.ResetAnimeTitles();
series.ResetPreferredTitle();
series.ResetPreferredOverview();
_groupService.UpdateStatsFromTopLevel(series?.AnimeGroup?.TopLevelAnimeGroup, false, false);


return NoContent();
}

Expand Down

0 comments on commit 079f80b

Please sign in to comment.