diff options
| author | Shadowghost <Ghost_of_Stone@web.de> | 2026-05-13 13:46:46 +0200 |
|---|---|---|
| committer | Shadowghost <Ghost_of_Stone@web.de> | 2026-05-13 13:46:46 +0200 |
| commit | 5165e4e2d421b2358582f691090ceb4bb220745e (patch) | |
| tree | b595ebb2be8010df54d45eeb82114c81c8f87003 /Jellyfin.Server.Implementations/Item/ChapterRepository.cs | |
| parent | 6014ad6ef2b2ab071d5d6fc755fa27a8d6e185f5 (diff) | |
Order chapter response by start time
Diffstat (limited to 'Jellyfin.Server.Implementations/Item/ChapterRepository.cs')
| -rw-r--r-- | Jellyfin.Server.Implementations/Item/ChapterRepository.cs | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/Jellyfin.Server.Implementations/Item/ChapterRepository.cs b/Jellyfin.Server.Implementations/Item/ChapterRepository.cs index 98700f3224..f7d76517e1 100644 --- a/Jellyfin.Server.Implementations/Item/ChapterRepository.cs +++ b/Jellyfin.Server.Implementations/Item/ChapterRepository.cs @@ -55,6 +55,7 @@ public class ChapterRepository : IChapterRepository { using var context = _dbProvider.CreateDbContext(); return context.Chapters.AsNoTracking().Where(e => e.ItemId.Equals(baseItemId)) + .OrderBy(e => e.StartPositionTicks) .Select(e => new { chapter = e, @@ -69,18 +70,16 @@ public class ChapterRepository : IChapterRepository public void SaveChapters(Guid itemId, IReadOnlyList<ChapterInfo> chapters) { using var context = _dbProvider.CreateDbContext(); - using (var transaction = context.Database.BeginTransaction()) + using var transaction = context.Database.BeginTransaction(); + context.Chapters.Where(e => e.ItemId.Equals(itemId)).ExecuteDelete(); + for (var i = 0; i < chapters.Count; i++) { - context.Chapters.Where(e => e.ItemId.Equals(itemId)).ExecuteDelete(); - for (var i = 0; i < chapters.Count; i++) - { - var chapter = chapters[i]; - context.Chapters.Add(Map(chapter, i, itemId)); - } - - context.SaveChanges(); - transaction.Commit(); + var chapter = chapters[i]; + context.Chapters.Add(Map(chapter, i, itemId)); } + + context.SaveChanges(); + transaction.Commit(); } /// <inheritdoc /> |
