mirror of
https://github.com/zoriya/Kyoo.git
synced 2025-06-06 15:14:13 -04:00
Making merge of lists work well
This commit is contained in:
parent
7e873aaed5
commit
e2f76b62e2
@ -48,7 +48,7 @@ namespace Kyoo.Models
|
|||||||
Overview = collection.Overview;
|
Overview = collection.Overview;
|
||||||
if (ImgPrimary == null)
|
if (ImgPrimary == null)
|
||||||
ImgPrimary = collection.ImgPrimary;
|
ImgPrimary = collection.ImgPrimary;
|
||||||
Shows = Shows == null ? collection.Shows : Shows.Concat(collection.Shows);
|
Shows = Utility.MergeLists(Shows, collection.Shows, (x, y) => x.Slug == y.Slug);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -109,8 +109,8 @@ namespace Kyoo.Models
|
|||||||
ID = other.ID;
|
ID = other.ID;
|
||||||
Slug ??= other.Slug;
|
Slug ??= other.Slug;
|
||||||
Title ??= other.Title;
|
Title ??= other.Title;
|
||||||
Aliases = Aliases == null ? other.Aliases : Aliases.Concat(other.Aliases).ToArray();
|
Aliases = Utility.MergeLists(Aliases, other.Aliases).ToArray();
|
||||||
Genres = Genres == null ? other.Genres : Genres.Concat(other.Genres);
|
Genres = Utility.MergeLists(Genres, other.Genres, (x, y) => x.Slug == y.Slug);
|
||||||
Path ??= other.Path;
|
Path ??= other.Path;
|
||||||
Overview ??= other.Overview;
|
Overview ??= other.Overview;
|
||||||
TrailerUrl ??= other.TrailerUrl;
|
TrailerUrl ??= other.TrailerUrl;
|
||||||
@ -121,6 +121,8 @@ namespace Kyoo.Models
|
|||||||
ImgThumb ??= other.ImgThumb;
|
ImgThumb ??= other.ImgThumb;
|
||||||
ImgLogo ??= other.ImgLogo;
|
ImgLogo ??= other.ImgLogo;
|
||||||
ImgBackdrop ??= other.ImgBackdrop;
|
ImgBackdrop ??= other.ImgBackdrop;
|
||||||
|
if (other.Studio != null)
|
||||||
|
Studio ??= other.Studio;
|
||||||
ExternalIDs = string.Join('|', ExternalIDs, other.ExternalIDs);
|
ExternalIDs = string.Join('|', ExternalIDs, other.ExternalIDs);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
@ -1,3 +1,7 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
using Kyoo.Models;
|
using Kyoo.Models;
|
||||||
|
|
||||||
@ -58,5 +62,17 @@ namespace Kyoo
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static IEnumerable<T> MergeLists<T>(IEnumerable<T> first, IEnumerable<T> second, Func<T, T, bool> isEqual = null)
|
||||||
|
{
|
||||||
|
if (first == null)
|
||||||
|
return second;
|
||||||
|
if (second == null)
|
||||||
|
return first;
|
||||||
|
List<T> list = first.ToList();
|
||||||
|
if (isEqual == null)
|
||||||
|
isEqual = (x, y) => x.Equals(y);
|
||||||
|
return list.Concat(second.Where(x => !list.Any(y => isEqual(x, y))));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -16,6 +16,10 @@
|
|||||||
<StartupObject>Kyoo.Program</StartupObject>
|
<StartupObject>Kyoo.Program</StartupObject>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
|
||||||
|
<OutputPath>bin/Release/</OutputPath>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="IdentityServer4" Version="3.1.2" />
|
<PackageReference Include="IdentityServer4" Version="3.1.2" />
|
||||||
<PackageReference Include="IdentityServer4.AspNetIdentity" Version="3.1.2" />
|
<PackageReference Include="IdentityServer4.AspNetIdentity" Version="3.1.2" />
|
||||||
|
Loading…
x
Reference in New Issue
Block a user