mirror of
https://github.com/zoriya/Kyoo.git
synced 2025-06-01 04:34:50 -04:00
Fix formatting
This commit is contained in:
parent
20963c021b
commit
4810db554e
@ -18,16 +18,7 @@
|
|||||||
* along with Kyoo. If not, see <https://www.gnu.org/licenses/>.
|
* along with Kyoo. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {
|
import { HR, Icon, IconButton, Menu, P, PressableFeedback, tooltip, ts } from "@kyoo/primitives";
|
||||||
HR,
|
|
||||||
Icon,
|
|
||||||
IconButton,
|
|
||||||
Menu,
|
|
||||||
P,
|
|
||||||
PressableFeedback,
|
|
||||||
tooltip,
|
|
||||||
ts,
|
|
||||||
} from "@kyoo/primitives";
|
|
||||||
import ArrowDownward from "@material-symbols/svg-400/rounded/arrow_downward.svg";
|
import ArrowDownward from "@material-symbols/svg-400/rounded/arrow_downward.svg";
|
||||||
import ArrowUpward from "@material-symbols/svg-400/rounded/arrow_upward.svg";
|
import ArrowUpward from "@material-symbols/svg-400/rounded/arrow_upward.svg";
|
||||||
import GridView from "@material-symbols/svg-400/rounded/grid_view.svg";
|
import GridView from "@material-symbols/svg-400/rounded/grid_view.svg";
|
||||||
@ -59,13 +50,12 @@ const SortTrigger = forwardRef<View, PressableProps & { sortKey: string }>(funct
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
const MediaTypeTrigger = forwardRef<View, PressableProps & { mediaType: MediaType }>(function MediaTypeTrigger(
|
const MediaTypeTrigger = forwardRef<View, PressableProps & { mediaType: MediaType }>(
|
||||||
{ mediaType, ...props },
|
function MediaTypeTrigger({ mediaType, ...props }, ref) {
|
||||||
ref,
|
|
||||||
) {
|
|
||||||
const { css } = useYoshiki();
|
const { css } = useYoshiki();
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const labelKey = mediaType !== MediaTypeAll ? `browse.mediatypekey.${mediaType.key}` : "browse.mediatypelabel";
|
const labelKey =
|
||||||
|
mediaType !== MediaTypeAll ? `browse.mediatypekey.${mediaType.key}` : "browse.mediatypelabel";
|
||||||
return (
|
return (
|
||||||
<PressableFeedback
|
<PressableFeedback
|
||||||
ref={ref}
|
ref={ref}
|
||||||
@ -76,7 +66,8 @@ const MediaTypeTrigger = forwardRef<View, PressableProps & { mediaType: MediaTyp
|
|||||||
<P>{t(labelKey as any)}</P>
|
<P>{t(labelKey as any)}</P>
|
||||||
</PressableFeedback>
|
</PressableFeedback>
|
||||||
);
|
);
|
||||||
});
|
},
|
||||||
|
);
|
||||||
|
|
||||||
export const BrowseSettings = ({
|
export const BrowseSettings = ({
|
||||||
availableSorts,
|
availableSorts,
|
||||||
|
@ -32,9 +32,17 @@ import { DefaultLayout } from "../layout";
|
|||||||
import { ItemGrid } from "./grid";
|
import { ItemGrid } from "./grid";
|
||||||
import { BrowseSettings } from "./header";
|
import { BrowseSettings } from "./header";
|
||||||
import { ItemList } from "./list";
|
import { ItemList } from "./list";
|
||||||
import {MediaTypeAll, Layout, MediaTypes, SortBy, SortOrd, MediaTypeKey, MediaType} from "./types";
|
import {
|
||||||
|
MediaTypeAll,
|
||||||
|
Layout,
|
||||||
|
MediaTypes,
|
||||||
|
SortBy,
|
||||||
|
SortOrd,
|
||||||
|
MediaTypeKey,
|
||||||
|
MediaType,
|
||||||
|
} from "./types";
|
||||||
|
|
||||||
const { useParam } = createParam<{ sortBy?: string, mediaType?: string }>();
|
const { useParam } = createParam<{ sortBy?: string; mediaType?: string }>();
|
||||||
|
|
||||||
export const itemMap = (
|
export const itemMap = (
|
||||||
item: LibraryItem,
|
item: LibraryItem,
|
||||||
@ -52,9 +60,13 @@ export const itemMap = (
|
|||||||
item.kind === "show" ? item.watchStatus?.unseenEpisodesCount ?? item.episodesCount! : null,
|
item.kind === "show" ? item.watchStatus?.unseenEpisodesCount ?? item.episodesCount! : null,
|
||||||
});
|
});
|
||||||
|
|
||||||
const query = (mediaType: MediaType, sortKey?: SortBy, sortOrd?: SortOrd): QueryIdentifier<LibraryItem> => {
|
const query = (
|
||||||
|
mediaType: MediaType,
|
||||||
|
sortKey?: SortBy,
|
||||||
|
sortOrd?: SortOrd,
|
||||||
|
): QueryIdentifier<LibraryItem> => {
|
||||||
const filter = mediaType !== MediaTypeAll ? `kind eq ${mediaType.key}` : undefined;
|
const filter = mediaType !== MediaTypeAll ? `kind eq ${mediaType.key}` : undefined;
|
||||||
return ({
|
return {
|
||||||
parser: LibraryItemP,
|
parser: LibraryItemP,
|
||||||
path: ["items"],
|
path: ["items"],
|
||||||
infinite: true,
|
infinite: true,
|
||||||
@ -63,13 +75,13 @@ const query = (mediaType: MediaType, sortKey?: SortBy, sortOrd?: SortOrd): Query
|
|||||||
filter,
|
filter,
|
||||||
fields: ["watchStatus", "episodesCount"],
|
fields: ["watchStatus", "episodesCount"],
|
||||||
},
|
},
|
||||||
});
|
};
|
||||||
}
|
};
|
||||||
|
|
||||||
const getMediaTypeFromParam = (mediaTypeParam?: string): MediaType => {
|
const getMediaTypeFromParam = (mediaTypeParam?: string): MediaType => {
|
||||||
const mediaTypeKey = mediaTypeParam as MediaTypeKey || MediaTypeKey.All;
|
const mediaTypeKey = (mediaTypeParam as MediaTypeKey) || MediaTypeKey.All;
|
||||||
return MediaTypes.find(t => t.key === mediaTypeKey) ?? MediaTypeAll;
|
return MediaTypes.find((t) => t.key === mediaTypeKey) ?? MediaTypeAll;
|
||||||
}
|
};
|
||||||
|
|
||||||
export const BrowsePage: QueryPage = () => {
|
export const BrowsePage: QueryPage = () => {
|
||||||
const [sort, setSort] = useParam("sortBy");
|
const [sort, setSort] = useParam("sortBy");
|
||||||
@ -112,7 +124,5 @@ BrowsePage.getLayout = DefaultLayout;
|
|||||||
|
|
||||||
BrowsePage.getFetchUrls = ({ mediaType, sortBy }) => {
|
BrowsePage.getFetchUrls = ({ mediaType, sortBy }) => {
|
||||||
const mediaTypeObj = getMediaTypeFromParam(mediaType);
|
const mediaTypeObj = getMediaTypeFromParam(mediaType);
|
||||||
return[
|
return [query(mediaTypeObj, sortBy?.split("-")[0] as SortBy, sortBy?.split("-")[1] as SortOrd)];
|
||||||
query(mediaTypeObj, sortBy?.split("-")[0] as SortBy, sortBy?.split("-")[1] as SortOrd),
|
};
|
||||||
];
|
|
||||||
}
|
|
||||||
|
@ -64,14 +64,14 @@ export interface MediaType {
|
|||||||
|
|
||||||
export const MediaTypeAll: MediaType = {
|
export const MediaTypeAll: MediaType = {
|
||||||
key: MediaTypeKey.All,
|
key: MediaTypeKey.All,
|
||||||
icon: All
|
icon: All,
|
||||||
}
|
};
|
||||||
|
|
||||||
export const MediaTypes: MediaType[] = [
|
export const MediaTypes: MediaType[] = [
|
||||||
MediaTypeAll,
|
MediaTypeAll,
|
||||||
{
|
{
|
||||||
key: MediaTypeKey.Movie,
|
key: MediaTypeKey.Movie,
|
||||||
icon: Movie
|
icon: Movie,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
key: MediaTypeKey.Show,
|
key: MediaTypeKey.Show,
|
||||||
@ -79,6 +79,6 @@ export const MediaTypes: MediaType[] = [
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
key: MediaTypeKey.Collection,
|
key: MediaTypeKey.Collection,
|
||||||
icon: Collection
|
icon: Collection,
|
||||||
}
|
},
|
||||||
];
|
];
|
||||||
|
Loading…
x
Reference in New Issue
Block a user