mirror of
https://github.com/zoriya/Kyoo.git
synced 2025-05-30 19:54:16 -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/>.
|
||||
*/
|
||||
|
||||
import {
|
||||
HR,
|
||||
Icon,
|
||||
IconButton,
|
||||
Menu,
|
||||
P,
|
||||
PressableFeedback,
|
||||
tooltip,
|
||||
ts,
|
||||
} from "@kyoo/primitives";
|
||||
import { HR, Icon, IconButton, Menu, P, PressableFeedback, tooltip, ts } from "@kyoo/primitives";
|
||||
import ArrowDownward from "@material-symbols/svg-400/rounded/arrow_downward.svg";
|
||||
import ArrowUpward from "@material-symbols/svg-400/rounded/arrow_upward.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(
|
||||
{ mediaType, ...props },
|
||||
ref,
|
||||
) {
|
||||
const MediaTypeTrigger = forwardRef<View, PressableProps & { mediaType: MediaType }>(
|
||||
function MediaTypeTrigger({ mediaType, ...props }, ref) {
|
||||
const { css } = useYoshiki();
|
||||
const { t } = useTranslation();
|
||||
const labelKey = mediaType !== MediaTypeAll ? `browse.mediatypekey.${mediaType.key}` : "browse.mediatypelabel";
|
||||
const labelKey =
|
||||
mediaType !== MediaTypeAll ? `browse.mediatypekey.${mediaType.key}` : "browse.mediatypelabel";
|
||||
return (
|
||||
<PressableFeedback
|
||||
ref={ref}
|
||||
@ -76,7 +66,8 @@ const MediaTypeTrigger = forwardRef<View, PressableProps & { mediaType: MediaTyp
|
||||
<P>{t(labelKey as any)}</P>
|
||||
</PressableFeedback>
|
||||
);
|
||||
});
|
||||
},
|
||||
);
|
||||
|
||||
export const BrowseSettings = ({
|
||||
availableSorts,
|
||||
|
@ -32,9 +32,17 @@ import { DefaultLayout } from "../layout";
|
||||
import { ItemGrid } from "./grid";
|
||||
import { BrowseSettings } from "./header";
|
||||
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 = (
|
||||
item: LibraryItem,
|
||||
@ -52,9 +60,13 @@ export const itemMap = (
|
||||
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;
|
||||
return ({
|
||||
return {
|
||||
parser: LibraryItemP,
|
||||
path: ["items"],
|
||||
infinite: true,
|
||||
@ -63,13 +75,13 @@ const query = (mediaType: MediaType, sortKey?: SortBy, sortOrd?: SortOrd): Query
|
||||
filter,
|
||||
fields: ["watchStatus", "episodesCount"],
|
||||
},
|
||||
});
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
const getMediaTypeFromParam = (mediaTypeParam?: string): MediaType => {
|
||||
const mediaTypeKey = mediaTypeParam as MediaTypeKey || MediaTypeKey.All;
|
||||
return MediaTypes.find(t => t.key === mediaTypeKey) ?? MediaTypeAll;
|
||||
}
|
||||
const mediaTypeKey = (mediaTypeParam as MediaTypeKey) || MediaTypeKey.All;
|
||||
return MediaTypes.find((t) => t.key === mediaTypeKey) ?? MediaTypeAll;
|
||||
};
|
||||
|
||||
export const BrowsePage: QueryPage = () => {
|
||||
const [sort, setSort] = useParam("sortBy");
|
||||
@ -112,7 +124,5 @@ BrowsePage.getLayout = DefaultLayout;
|
||||
|
||||
BrowsePage.getFetchUrls = ({ mediaType, sortBy }) => {
|
||||
const mediaTypeObj = getMediaTypeFromParam(mediaType);
|
||||
return[
|
||||
query(mediaTypeObj, sortBy?.split("-")[0] as SortBy, sortBy?.split("-")[1] as SortOrd),
|
||||
];
|
||||
}
|
||||
return [query(mediaTypeObj, sortBy?.split("-")[0] as SortBy, sortBy?.split("-")[1] as SortOrd)];
|
||||
};
|
||||
|
@ -64,14 +64,14 @@ export interface MediaType {
|
||||
|
||||
export const MediaTypeAll: MediaType = {
|
||||
key: MediaTypeKey.All,
|
||||
icon: All
|
||||
}
|
||||
icon: All,
|
||||
};
|
||||
|
||||
export const MediaTypes: MediaType[] = [
|
||||
MediaTypeAll,
|
||||
{
|
||||
key: MediaTypeKey.Movie,
|
||||
icon: Movie
|
||||
icon: Movie,
|
||||
},
|
||||
{
|
||||
key: MediaTypeKey.Show,
|
||||
@ -79,6 +79,6 @@ export const MediaTypes: MediaType[] = [
|
||||
},
|
||||
{
|
||||
key: MediaTypeKey.Collection,
|
||||
icon: Collection
|
||||
}
|
||||
icon: Collection,
|
||||
},
|
||||
];
|
||||
|
Loading…
x
Reference in New Issue
Block a user