mirror of
https://github.com/zoriya/Kyoo.git
synced 2025-07-09 03:04:20 -04:00
Update front for new filter api and use includes when useful
This commit is contained in:
parent
29314d473f
commit
948f8694f2
@ -63,7 +63,18 @@ namespace Kyoo.Abstractions.Controllers
|
||||
public record Conglomerate(params Sort<T>[] List) : Sort<T>;
|
||||
|
||||
/// <summary>Sort randomly items</summary>
|
||||
public record Random(uint seed) : Sort<T>;
|
||||
public record Random(uint Seed) : Sort<T>
|
||||
{
|
||||
public Random()
|
||||
: this(0)
|
||||
{
|
||||
uint seed = BitConverter.ToUInt32(
|
||||
BitConverter.GetBytes(new System.Random().Next(int.MinValue, int.MaxValue)),
|
||||
0
|
||||
);
|
||||
Seed = seed;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>The default sort method for the given type.</summary>
|
||||
public record Default : Sort<T>
|
||||
|
@ -35,7 +35,7 @@ public sealed class ExpressionArgumentReplacer : ExpressionVisitor
|
||||
{
|
||||
if (_mapping.TryGetValue(node, out Expression? mappedArgument))
|
||||
return Visit(mappedArgument);
|
||||
return VisitParameter(node);
|
||||
return base.VisitParameter(node);
|
||||
}
|
||||
|
||||
public static Expression ReplaceParams(Expression expression, IEnumerable<ParameterExpression> epxParams, params ParameterExpression[] param)
|
||||
|
@ -94,6 +94,17 @@ public abstract class DapperRepository<T> : IRepository<T>
|
||||
/// <inheritdoc />
|
||||
public Task<T?> GetOrDefault(string slug, Include<T>? include = null)
|
||||
{
|
||||
if (slug == "random")
|
||||
{
|
||||
return Database.QuerySingle<T>(
|
||||
Sql,
|
||||
Config,
|
||||
Mapper,
|
||||
include,
|
||||
filter: null,
|
||||
new Sort<T>.Random()
|
||||
);
|
||||
}
|
||||
return Database.QuerySingle<T>(
|
||||
Sql,
|
||||
Config,
|
||||
|
@ -66,7 +66,7 @@ namespace Kyoo.Core
|
||||
builder.RegisterRepository<PeopleRepository>();
|
||||
builder.RegisterRepository<StudioRepository>();
|
||||
builder.RegisterRepository<UserRepository>();
|
||||
builder.RegisterType<NewsRepository>().InstancePerLifetimeScope();
|
||||
builder.RegisterRepository<NewsRepository>();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
|
@ -36,11 +36,7 @@ export const LibraryItemP = z.union([
|
||||
/*
|
||||
* Either a Show
|
||||
*/
|
||||
ShowP.and(
|
||||
z.object({
|
||||
kind: z.literal(ItemKind.Show),
|
||||
}),
|
||||
).transform((x) => ({ ...x, playHref: `/watch/${x.slug}-s1e1` })),
|
||||
ShowP.and(z.object({ kind: z.literal(ItemKind.Show) })),
|
||||
/*
|
||||
* Or a Movie
|
||||
*/
|
||||
|
@ -66,7 +66,7 @@ const ShowHeader = forwardRef<View, ViewProps & { slug: string }>(function ShowH
|
||||
)}
|
||||
>
|
||||
<Header type="show" query={query(slug)} />
|
||||
<DetailsCollections type="movie" slug={slug} />
|
||||
<DetailsCollections type="show" slug={slug} />
|
||||
{/* <Staff slug={slug} /> */}
|
||||
<SvgWave
|
||||
fill={theme.variant.background}
|
||||
@ -83,7 +83,7 @@ const query = (slug: string): QueryIdentifier<Show> => ({
|
||||
parser: ShowP,
|
||||
path: ["shows", slug],
|
||||
params: {
|
||||
fields: ["studio", "firstEpisode", "collections"],
|
||||
fields: ["studio", "firstEpisode"],
|
||||
},
|
||||
});
|
||||
|
||||
|
@ -105,7 +105,7 @@ GenreGrid.query = (genre: Genre): QueryIdentifier<LibraryItem> => ({
|
||||
infinite: true,
|
||||
path: ["items"],
|
||||
params: {
|
||||
genres: genre,
|
||||
filter: `genres has ${genre}`,
|
||||
sortBy: "random",
|
||||
// Limit the inital numbers of items
|
||||
limit: 10,
|
||||
|
@ -105,4 +105,7 @@ export const Header = ({
|
||||
Header.query = (): QueryIdentifier<LibraryItem> => ({
|
||||
parser: LibraryItemP,
|
||||
path: ["items", "random"],
|
||||
params: {
|
||||
fields: ["firstEpisode"],
|
||||
},
|
||||
});
|
||||
|
@ -220,5 +220,6 @@ Recommanded.query = (): QueryIdentifier<LibraryItem> => ({
|
||||
params: {
|
||||
sortBy: "random",
|
||||
limit: 6,
|
||||
fields: ["firstEpisode"],
|
||||
},
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user