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>;
|
public record Conglomerate(params Sort<T>[] List) : Sort<T>;
|
||||||
|
|
||||||
/// <summary>Sort randomly items</summary>
|
/// <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>
|
/// <summary>The default sort method for the given type.</summary>
|
||||||
public record Default : Sort<T>
|
public record Default : Sort<T>
|
||||||
|
@ -35,7 +35,7 @@ public sealed class ExpressionArgumentReplacer : ExpressionVisitor
|
|||||||
{
|
{
|
||||||
if (_mapping.TryGetValue(node, out Expression? mappedArgument))
|
if (_mapping.TryGetValue(node, out Expression? mappedArgument))
|
||||||
return Visit(mappedArgument);
|
return Visit(mappedArgument);
|
||||||
return VisitParameter(node);
|
return base.VisitParameter(node);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Expression ReplaceParams(Expression expression, IEnumerable<ParameterExpression> epxParams, params ParameterExpression[] param)
|
public static Expression ReplaceParams(Expression expression, IEnumerable<ParameterExpression> epxParams, params ParameterExpression[] param)
|
||||||
|
@ -94,6 +94,17 @@ public abstract class DapperRepository<T> : IRepository<T>
|
|||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public Task<T?> GetOrDefault(string slug, Include<T>? include = null)
|
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>(
|
return Database.QuerySingle<T>(
|
||||||
Sql,
|
Sql,
|
||||||
Config,
|
Config,
|
||||||
|
@ -66,7 +66,7 @@ namespace Kyoo.Core
|
|||||||
builder.RegisterRepository<PeopleRepository>();
|
builder.RegisterRepository<PeopleRepository>();
|
||||||
builder.RegisterRepository<StudioRepository>();
|
builder.RegisterRepository<StudioRepository>();
|
||||||
builder.RegisterRepository<UserRepository>();
|
builder.RegisterRepository<UserRepository>();
|
||||||
builder.RegisterType<NewsRepository>().InstancePerLifetimeScope();
|
builder.RegisterRepository<NewsRepository>();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
|
@ -36,11 +36,7 @@ export const LibraryItemP = z.union([
|
|||||||
/*
|
/*
|
||||||
* Either a Show
|
* Either a Show
|
||||||
*/
|
*/
|
||||||
ShowP.and(
|
ShowP.and(z.object({ kind: z.literal(ItemKind.Show) })),
|
||||||
z.object({
|
|
||||||
kind: z.literal(ItemKind.Show),
|
|
||||||
}),
|
|
||||||
).transform((x) => ({ ...x, playHref: `/watch/${x.slug}-s1e1` })),
|
|
||||||
/*
|
/*
|
||||||
* Or a Movie
|
* Or a Movie
|
||||||
*/
|
*/
|
||||||
|
@ -66,7 +66,7 @@ const ShowHeader = forwardRef<View, ViewProps & { slug: string }>(function ShowH
|
|||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
<Header type="show" query={query(slug)} />
|
<Header type="show" query={query(slug)} />
|
||||||
<DetailsCollections type="movie" slug={slug} />
|
<DetailsCollections type="show" slug={slug} />
|
||||||
{/* <Staff slug={slug} /> */}
|
{/* <Staff slug={slug} /> */}
|
||||||
<SvgWave
|
<SvgWave
|
||||||
fill={theme.variant.background}
|
fill={theme.variant.background}
|
||||||
@ -83,7 +83,7 @@ const query = (slug: string): QueryIdentifier<Show> => ({
|
|||||||
parser: ShowP,
|
parser: ShowP,
|
||||||
path: ["shows", slug],
|
path: ["shows", slug],
|
||||||
params: {
|
params: {
|
||||||
fields: ["studio", "firstEpisode", "collections"],
|
fields: ["studio", "firstEpisode"],
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -105,7 +105,7 @@ GenreGrid.query = (genre: Genre): QueryIdentifier<LibraryItem> => ({
|
|||||||
infinite: true,
|
infinite: true,
|
||||||
path: ["items"],
|
path: ["items"],
|
||||||
params: {
|
params: {
|
||||||
genres: genre,
|
filter: `genres has ${genre}`,
|
||||||
sortBy: "random",
|
sortBy: "random",
|
||||||
// Limit the inital numbers of items
|
// Limit the inital numbers of items
|
||||||
limit: 10,
|
limit: 10,
|
||||||
|
@ -105,4 +105,7 @@ export const Header = ({
|
|||||||
Header.query = (): QueryIdentifier<LibraryItem> => ({
|
Header.query = (): QueryIdentifier<LibraryItem> => ({
|
||||||
parser: LibraryItemP,
|
parser: LibraryItemP,
|
||||||
path: ["items", "random"],
|
path: ["items", "random"],
|
||||||
|
params: {
|
||||||
|
fields: ["firstEpisode"],
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
@ -220,5 +220,6 @@ Recommanded.query = (): QueryIdentifier<LibraryItem> => ({
|
|||||||
params: {
|
params: {
|
||||||
sortBy: "random",
|
sortBy: "random",
|
||||||
limit: 6,
|
limit: 6,
|
||||||
|
fields: ["firstEpisode"],
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user