Compare commits

..

No commits in common. "157d46ee2ecc137e4c176af51fbc145a89683710" and "977b40c403e5a4c01211730003297d27910cf4c1" have entirely different histories.

10 changed files with 9 additions and 77 deletions

View file

@ -20,10 +20,7 @@ public static class HistoryEndpoint
if (results == null)
await repository.AddAsync(history, ct);
else
{
results.Update(history);
await repository.UpdateAsync(results, ct);
}
await repository.UpdateAsync(history, ct);
return Results.Ok();
});

View file

@ -20,11 +20,7 @@ public static class PlaylistEndpoint
if (results == null)
await repository.AddAsync(playlist, ct);
else
{
results.Update(playlist);
await repository.UpdateAsync(results, ct);
}
await repository.UpdateAsync(playlist, ct);
return Results.Ok();
});

View file

@ -20,11 +20,7 @@ public static class ProfileEndpoint
if (res == null)
await repository.AddAsync(profile, ct);
else
{
res.Update(profile);
await repository.UpdateAsync(res, ct);
}
await repository.UpdateAsync(profile, ct);
return Results.Ok();
});

View file

@ -17,14 +17,10 @@ public static class SearchHistoryEndpoint
group.MapPost("/", async (IRepository<SearchHistory> repository, CancellationToken ct, SearchHistory history) =>
{
var result = await repository.GetByIdAsync(history._id, ct);
if (result == null)
await repository.AddAsync(history, ct);
if (result != null)
await repository.UpdateAsync(history, ct);
else
{
result.Update(history);
await repository.UpdateAsync(result, ct);
}
await repository.AddAsync(history, ct);
return Results.Ok();
});

View file

@ -22,10 +22,7 @@ public static class SettingEndpoint
if (res == null)
await repository.AddAsync(setting, ct);
else
{
res.Update(setting);
await repository.UpdateAsync(res, ct);
}
await repository.UpdateAsync(setting, ct);
return Results.Ok();
});

View file

@ -1,6 +1,5 @@
using System.ComponentModel.DataAnnotations;
using System.Diagnostics.CodeAnalysis;
using Microsoft.EntityFrameworkCore.Query.Internal;
namespace FreeTubeSync.Model;
@ -19,20 +18,7 @@ public class Playlist
{
if (other.playlistName != playlistName) playlistName = other.playlistName;
if (other.@protected != @protected) @protected = other.@protected;
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.videos.Count != videos.Count) videos = other.videos;
if (other.createdAt != createdAt) createdAt = other.createdAt;
if (other.lastUpdatedAt != lastUpdatedAt) lastUpdatedAt = other.lastUpdatedAt;
}

View file

@ -18,19 +18,6 @@ public class Profile
if (other.name != name) name = other.name;
if (other.bgColor != bgColor) bgColor = other.bgColor;
if (other.textColor != textColor) textColor = other.textColor;
var remove = new List<Subscription>();
foreach (var sub in subscriptions)
{
if (other.subscriptions.Any(x => x.id == sub.id)) continue;
remove.Add(sub);
}
subscriptions.RemoveAll(x => remove.Contains(x));
remove.Clear();
foreach (var sub in other.subscriptions)
{
if (subscriptions.Any(x => x.id == sub.id)) continue;
remove.Add(sub);
}
subscriptions.AddRange(remove);
if (other.subscriptions.Count != subscriptions.Count) subscriptions = other.subscriptions;
}
}

View file

@ -22,9 +22,4 @@ public class Setting
#pragma warning restore CS8603
set => ValueJson = JsonSerializer.Serialize(value);
}
public void Update(Setting other)
{
Value = other.Value;
}
}

View file

@ -10,10 +10,4 @@ public class Subscription
public required string id { get; set; }
public required string name { get; set; }
public string? thumbnail { get; set; }
public void Update(Subscription other)
{
name = other.name;
thumbnail = other.thumbnail;
}
}

View file

@ -16,16 +16,4 @@ public class Video
public long timeAdded { get; set; }
[Key] public string playlistItemId { get; set; } = string.Empty;
public string type { get; set; } = string.Empty;
public void Update(Video other)
{
videoId = other.videoId;
title = other.title;
author = other.author;
authorId = other.authorId;
lengthSeconds = other.lengthSeconds;
pubished = other.pubished;
timeAdded = other.timeAdded;
type = other.type;
}
}