mirror of
https://github.com/zoriya/Kyoo.git
synced 2025-06-23 15:30:34 -04:00
Fix type issues
This commit is contained in:
parent
3d30d65184
commit
7b56924466
@ -33,7 +33,7 @@ import {
|
|||||||
tooltip,
|
tooltip,
|
||||||
ts,
|
ts,
|
||||||
} from "@kyoo/primitives";
|
} from "@kyoo/primitives";
|
||||||
import { Chapter, Font, Track, WatchItem } from "@kyoo/models";
|
import { Chapter, Subtitle, WatchItem } from "@kyoo/models";
|
||||||
import { useAtomValue, useSetAtom, useAtom } from "jotai";
|
import { useAtomValue, useSetAtom, useAtom } from "jotai";
|
||||||
import { Platform, Pressable, View, ViewProps } from "react-native";
|
import { Platform, Pressable, View, ViewProps } from "react-native";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
@ -69,8 +69,8 @@ export const Hover = ({
|
|||||||
poster?: string | null;
|
poster?: string | null;
|
||||||
chapters?: Chapter[];
|
chapters?: Chapter[];
|
||||||
qualities?: WatchItem["link"]
|
qualities?: WatchItem["link"]
|
||||||
subtitles?: Track[];
|
subtitles?: Subtitle[];
|
||||||
fonts?: Font[];
|
fonts?: string[];
|
||||||
previousSlug?: string | null;
|
previousSlug?: string | null;
|
||||||
nextSlug?: string | null;
|
nextSlug?: string | null;
|
||||||
onMenuOpen: () => void;
|
onMenuOpen: () => void;
|
||||||
|
@ -18,7 +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 { Font, Track } from "@kyoo/models";
|
import { Subtitle } from "@kyoo/models";
|
||||||
import { atom, useSetAtom } from "jotai";
|
import { atom, useSetAtom } from "jotai";
|
||||||
import { useRouter } from "solito/router";
|
import { useRouter } from "solito/router";
|
||||||
import { useEffect } from "react";
|
import { useEffect } from "react";
|
||||||
@ -41,7 +41,7 @@ type Action =
|
|||||||
| { type: "seekTo"; value: number }
|
| { type: "seekTo"; value: number }
|
||||||
| { type: "seekPercent"; value: number }
|
| { type: "seekPercent"; value: number }
|
||||||
| { type: "volume"; value: number }
|
| { type: "volume"; value: number }
|
||||||
| { type: "subtitle"; subtitles: Track[]; fonts: Font[] };
|
| { type: "subtitle"; subtitles: Subtitle[]; fonts: string[] };
|
||||||
|
|
||||||
export const reducerAtom = atom(null, (get, set, action: Action) => {
|
export const reducerAtom = atom(null, (get, set, action: Action) => {
|
||||||
const duration = get(durationAtom);
|
const duration = get(durationAtom);
|
||||||
@ -70,7 +70,7 @@ export const reducerAtom = atom(null, (get, set, action: Action) => {
|
|||||||
break;
|
break;
|
||||||
case "subtitle":
|
case "subtitle":
|
||||||
const subtitle = get(subtitleAtom);
|
const subtitle = get(subtitleAtom);
|
||||||
const index = subtitle ? action.subtitles.findIndex((x) => x.id === subtitle.id) : -1;
|
const index = subtitle ? action.subtitles.findIndex((x) => x.index === subtitle.index) : -1;
|
||||||
set(
|
set(
|
||||||
subtitleAtom,
|
subtitleAtom,
|
||||||
index === -1 ? null : action.subtitles[(index + 1) % action.subtitles.length],
|
index === -1 ? null : action.subtitles[(index + 1) % action.subtitles.length],
|
||||||
@ -80,8 +80,8 @@ export const reducerAtom = atom(null, (get, set, action: Action) => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
export const useVideoKeyboard = (
|
export const useVideoKeyboard = (
|
||||||
subtitles?: Track[],
|
subtitles?: Subtitle[],
|
||||||
fonts?: Font[],
|
fonts?: string[],
|
||||||
previousEpisode?: string,
|
previousEpisode?: string,
|
||||||
nextEpisode?: string,
|
nextEpisode?: string,
|
||||||
) => {
|
) => {
|
||||||
|
@ -18,7 +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 { Track, WatchItem, Font } from "@kyoo/models";
|
import { Subtitle, WatchItem } from "@kyoo/models";
|
||||||
import { atom, useAtom, useAtomValue, useSetAtom } from "jotai";
|
import { atom, useAtom, useAtomValue, useSetAtom } from "jotai";
|
||||||
import { ElementRef, memo, useEffect, useLayoutEffect, useRef, useState } from "react";
|
import { ElementRef, memo, useEffect, useLayoutEffect, useRef, useState } from "react";
|
||||||
import NativeVideo, { VideoProperties as VideoProps } from "./video";
|
import NativeVideo, { VideoProperties as VideoProps } from "./video";
|
||||||
@ -72,7 +72,7 @@ export const fullscreenAtom = atom(
|
|||||||
);
|
);
|
||||||
const privateFullscreen = atom(false);
|
const privateFullscreen = atom(false);
|
||||||
|
|
||||||
export const subtitleAtom = atom<Track | null>(null);
|
export const subtitleAtom = atom<Subtitle | null>(null);
|
||||||
|
|
||||||
export const Video = memo(function _Video({
|
export const Video = memo(function _Video({
|
||||||
links,
|
links,
|
||||||
@ -82,9 +82,9 @@ export const Video = memo(function _Video({
|
|||||||
...props
|
...props
|
||||||
}: {
|
}: {
|
||||||
links?: WatchItem["link"];
|
links?: WatchItem["link"];
|
||||||
subtitles?: WatchItem["subtitles"];
|
subtitles?: Subtitle[];
|
||||||
setError: (error: string | undefined) => void;
|
setError: (error: string | undefined) => void;
|
||||||
fonts?: Font[];
|
fonts?: string[];
|
||||||
} & Partial<VideoProps>) {
|
} & Partial<VideoProps>) {
|
||||||
const ref = useRef<ElementRef<typeof NativeVideo> | null>(null);
|
const ref = useRef<ElementRef<typeof NativeVideo> | null>(null);
|
||||||
const [isPlaying, setPlay] = useAtom(playAtom);
|
const [isPlaying, setPlay] = useAtom(playAtom);
|
||||||
|
@ -20,19 +20,19 @@
|
|||||||
|
|
||||||
declare module "react-native-video" {
|
declare module "react-native-video" {
|
||||||
interface VideoProperties {
|
interface VideoProperties {
|
||||||
fonts?: Font[];
|
fonts?: string[];
|
||||||
|
subtitles?: Subtitle[]
|
||||||
onPlayPause: (isPlaying: boolean) => void;
|
onPlayPause: (isPlaying: boolean) => void;
|
||||||
onMediaUnsupported?: () => void;
|
onMediaUnsupported?: () => void;
|
||||||
}
|
}
|
||||||
export type VideoProps = Omit<VideoProperties, "source"> & {
|
export type VideoProps = Omit<VideoProperties, "source"> & {
|
||||||
source: { uri: string; hls: string };
|
source: { uri: string; hls: string };
|
||||||
subtitles?: WatchItem["subtitles"];
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export * from "react-native-video";
|
export * from "react-native-video";
|
||||||
|
|
||||||
import { Font, getToken, WatchItem } from "@kyoo/models";
|
import { Subtitle, getToken } from "@kyoo/models";
|
||||||
import { IconButton, Menu } from "@kyoo/primitives";
|
import { IconButton, Menu } from "@kyoo/primitives";
|
||||||
import { ComponentProps, forwardRef, useEffect, useRef } from "react";
|
import { ComponentProps, forwardRef, useEffect, useRef } from "react";
|
||||||
import { atom, useAtom, useAtomValue, useSetAtom } from "jotai";
|
import { atom, useAtom, useAtomValue, useSetAtom } from "jotai";
|
||||||
|
Loading…
x
Reference in New Issue
Block a user