Updated Playlist
Updated code to filter out videos that have been removed from the playlist, and insert new ones into the list in the Update() function.
This commit is contained in:
parent
977b40c403
commit
561ba4f34a
1 changed files with 15 additions and 1 deletions
|
|
@ -1,5 +1,6 @@
|
|||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using Microsoft.EntityFrameworkCore.Query.Internal;
|
||||
|
||||
namespace FreeTubeSync.Model;
|
||||
|
||||
|
|
@ -18,7 +19,20 @@ public class Playlist
|
|||
{
|
||||
if (other.playlistName != playlistName) playlistName = other.playlistName;
|
||||
if (other.@protected != @protected) @protected = other.@protected;
|
||||
if (other.videos.Count != videos.Count) videos = other.videos;
|
||||
var remove = new List<Video>();
|
||||
foreach (var vid in videos)
|
||||
{
|
||||
if (other.videos.Any(x => x.playlistItemId == vid.playlistItemId)) continue;
|
||||
remove.Add(vid);
|
||||
}
|
||||
videos.RemoveAll(x => remove.Contains(x));
|
||||
remove.Clear();
|
||||
foreach (var vid in other.videos)
|
||||
{
|
||||
if (videos.Any(x => x.playlistItemId == vid.playlistItemId)) continue;
|
||||
remove.Add(vid);
|
||||
}
|
||||
videos.AddRange(remove);
|
||||
if (other.createdAt != createdAt) createdAt = other.createdAt;
|
||||
if (other.lastUpdatedAt != lastUpdatedAt) lastUpdatedAt = other.lastUpdatedAt;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue