mirror of
https://github.com/streamyfin/streamyfin.git
synced 2025-08-20 18:37:18 +02:00
fix: refactor to use enums
This commit is contained in:
@@ -1,51 +1,67 @@
|
|||||||
import {
|
import { atom } from "jotai";
|
||||||
ItemFilter,
|
|
||||||
ItemSortBy,
|
export enum SortByOption {
|
||||||
NameGuidPair,
|
Default = "Default",
|
||||||
SortOrder,
|
SortName = "SortName",
|
||||||
} from "@jellyfin/sdk/lib/generated-client/models";
|
CommunityRating = "CommunityRating",
|
||||||
import { atom, useAtom } from "jotai";
|
CriticRating = "CriticRating",
|
||||||
|
DateCreated = "DateCreated",
|
||||||
|
DatePlayed = "DatePlayed",
|
||||||
|
PlayCount = "PlayCount",
|
||||||
|
ProductionYear = "ProductionYear",
|
||||||
|
Runtime = "Runtime",
|
||||||
|
OfficialRating = "OfficialRating",
|
||||||
|
PremiereDate = "PremiereDate",
|
||||||
|
StartDate = "StartDate",
|
||||||
|
IsUnplayed = "IsUnplayed",
|
||||||
|
IsPlayed = "IsPlayed",
|
||||||
|
AirTime = "AirTime",
|
||||||
|
Studio = "Studio",
|
||||||
|
IsFavoriteOrLiked = "IsFavoriteOrLiked",
|
||||||
|
Random = "Random",
|
||||||
|
}
|
||||||
|
|
||||||
|
export enum SortOrderOption {
|
||||||
|
Ascending = "Ascending",
|
||||||
|
Descending = "Descending",
|
||||||
|
}
|
||||||
|
|
||||||
export const sortOptions: {
|
export const sortOptions: {
|
||||||
key: ItemSortBy;
|
key: SortByOption;
|
||||||
value: string;
|
value: string;
|
||||||
}[] = [
|
}[] = [
|
||||||
{ key: "Default", value: "Default" },
|
{ key: SortByOption.Default, value: "Default" },
|
||||||
{ key: "SortName", value: "Name" },
|
{ key: SortByOption.SortName, value: "Name" },
|
||||||
{ key: "CommunityRating", value: "Community Rating" },
|
{ key: SortByOption.CommunityRating, value: "Community Rating" },
|
||||||
{ key: "CriticRating", value: "Critics Rating" },
|
{ key: SortByOption.CriticRating, value: "Critics Rating" },
|
||||||
{ key: "DateCreated", value: "Date Added" },
|
{ key: SortByOption.DateCreated, value: "Date Added" },
|
||||||
// Only works for shows (last episode added) keeping for future ref.
|
{ key: SortByOption.DatePlayed, value: "Date Played" },
|
||||||
// { key: "DateLastContentAdded", value: "Content Added" },
|
{ key: SortByOption.PlayCount, value: "Play Count" },
|
||||||
{ key: "DatePlayed", value: "Date Played" },
|
{ key: SortByOption.ProductionYear, value: "Production Year" },
|
||||||
{ key: "PlayCount", value: "Play Count" },
|
{ key: SortByOption.Runtime, value: "Runtime" },
|
||||||
{ key: "ProductionYear", value: "Production Year" },
|
{ key: SortByOption.OfficialRating, value: "Official Rating" },
|
||||||
{ key: "Runtime", value: "Runtime" },
|
{ key: SortByOption.PremiereDate, value: "Premiere Date" },
|
||||||
{ key: "OfficialRating", value: "Official Rating" },
|
{ key: SortByOption.StartDate, value: "Start Date" },
|
||||||
{ key: "PremiereDate", value: "Premiere Date" },
|
{ key: SortByOption.IsUnplayed, value: "Is Unplayed" },
|
||||||
{ key: "StartDate", value: "Start Date" },
|
{ key: SortByOption.IsPlayed, value: "Is Played" },
|
||||||
{ key: "IsUnplayed", value: "Is Unplayed" },
|
{ key: SortByOption.AirTime, value: "Air Time" },
|
||||||
{ key: "IsPlayed", value: "Is Played" },
|
{ key: SortByOption.Studio, value: "Studio" },
|
||||||
// Broken in JF
|
{ key: SortByOption.IsFavoriteOrLiked, value: "Is Favorite Or Liked" },
|
||||||
// { key: "VideoBitRate", value: "Video Bit Rate" },
|
{ key: SortByOption.Random, value: "Random" },
|
||||||
{ key: "AirTime", value: "Air Time" },
|
|
||||||
{ key: "Studio", value: "Studio" },
|
|
||||||
{ key: "IsFavoriteOrLiked", value: "Is Favorite Or Liked" },
|
|
||||||
{ key: "Random", value: "Random" },
|
|
||||||
];
|
];
|
||||||
|
|
||||||
export const sortOrderOptions: {
|
export const sortOrderOptions: {
|
||||||
key: SortOrder;
|
key: SortOrderOption;
|
||||||
value: string;
|
value: string;
|
||||||
}[] = [
|
}[] = [
|
||||||
{ key: "Ascending", value: "Ascending" },
|
{ key: SortOrderOption.Ascending, value: "Ascending" },
|
||||||
{ key: "Descending", value: "Descending" },
|
{ key: SortOrderOption.Descending, value: "Descending" },
|
||||||
];
|
];
|
||||||
|
|
||||||
export const genreFilterAtom = atom<string[]>([]);
|
export const genreFilterAtom = atom<string[]>([]);
|
||||||
export const tagsFilterAtom = atom<string[]>([]);
|
export const tagsFilterAtom = atom<string[]>([]);
|
||||||
export const yearFilterAtom = atom<string[]>([]);
|
export const yearFilterAtom = atom<string[]>([]);
|
||||||
export const sortByAtom = atom<[typeof sortOptions][number]>([sortOptions[0]]);
|
export const sortByAtom = atom<SortByOption[]>([SortByOption.Default]);
|
||||||
export const sortOrderAtom = atom<[typeof sortOrderOptions][number]>([
|
export const sortOrderAtom = atom<SortOrderOption[]>([
|
||||||
sortOrderOptions[0],
|
SortOrderOption.Ascending,
|
||||||
]);
|
]);
|
||||||
|
|||||||
Reference in New Issue
Block a user