2
0

Check if tags and authors are the same on Manga equals.

UpdateManga performs union/concat operation on alttitles, tags and authors
This commit is contained in:
Glax 2024-04-19 03:00:31 +02:00
parent 294ce01bc3
commit 95236daf41

View File

@ -12,14 +12,14 @@ namespace Tranga;
public struct Manga
{
public string sortName { get; private set; }
public List<string> authors { get; }
public List<string> authors { get; private set; }
// ReSharper disable once UnusedAutoPropertyAccessor.Global
public Dictionary<string,string> altTitles { get; }
public Dictionary<string,string> altTitles { get; private set; }
// ReSharper disable once MemberCanBePrivate.Global
public string? description { get; private set; }
public string[] tags { get; }
public string[] tags { get; private set; }
// ReSharper disable once UnusedAutoPropertyAccessor.Global
public string? coverUrl { get; }
public string? coverUrl { get; private set; }
public string? coverFileNameInCache { get; }
// ReSharper disable once UnusedAutoPropertyAccessor.Global
public Dictionary<string,string> links { get; }
@ -76,9 +76,10 @@ public struct Manga
{
this.sortName = newManga.sortName;
this.description = newManga.description;
foreach (string author in newManga.authors)
if(!this.authors.Contains(author))
this.authors.Add(author);
this.coverUrl = newManga.coverUrl;
this.authors = authors.Union(newManga.authors).ToList();
this.altTitles = altTitles.Concat(newManga.altTitles).ToDictionary(x => x.Key, x => x.Value);
this.tags = tags.Union(newManga.tags).ToArray();
this.status = newManga.status;
this.releaseStatus = newManga.releaseStatus;
this.year = newManga.year;
@ -94,7 +95,8 @@ public struct Manga
this.releaseStatus == compareManga.releaseStatus &&
this.sortName == compareManga.sortName &&
this.latestChapterAvailable.Equals(compareManga.latestChapterAvailable) &&
this.tags.SequenceEqual(compareManga.tags);
this.authors.All(a => compareManga.authors.Contains(a)) &&
this.tags.All(t => compareManga.tags.Contains(t));
}
public override string ToString()