mirror of
https://github.com/zoriya/Kyoo.git
synced 2025-05-24 02:02:36 -04:00
Move scrubbing vtt parsing to a hook
This commit is contained in:
parent
7193a599b7
commit
5efcfb8b61
@ -31,9 +31,9 @@ import { toTimerString } from "./left-buttons";
|
||||
|
||||
type Thumb = { to: number; url: string; x: number; y: number; width: number; height: number };
|
||||
|
||||
export const BottomScrubber = ({ url }: { url: string }) => {
|
||||
const { css } = useYoshiki();
|
||||
const { data, error } = useFetch(BottomScrubber.query(url));
|
||||
export const useScrubber = (url: string) => {
|
||||
const { data, error } = useFetch(useScrubber.query(url));
|
||||
// TODO: put the info here on the react-query cache to prevent multiples runs of this
|
||||
const info = useMemo(() => {
|
||||
if (!data) return [];
|
||||
|
||||
@ -67,6 +67,21 @@ export const BottomScrubber = ({ url }: { url: string }) => {
|
||||
return ret;
|
||||
}, [data]);
|
||||
|
||||
return { info, error } as const;
|
||||
};
|
||||
|
||||
useScrubber.query = (url: string): QueryIdentifier<string> => ({
|
||||
path: ["video", url, "thumbnails.vtt"],
|
||||
parser: null!,
|
||||
options: {
|
||||
plainText: true,
|
||||
},
|
||||
});
|
||||
|
||||
export const BottomScrubber = ({ url }: { url: string }) => {
|
||||
const { css } = useYoshiki();
|
||||
const { info, error } = useScrubber(url);
|
||||
|
||||
const progress = useAtomValue(progressAtom);
|
||||
const duration = useAtomValue(durationAtom);
|
||||
|
||||
@ -142,11 +157,3 @@ export const BottomScrubber = ({ url }: { url: string }) => {
|
||||
</View>
|
||||
);
|
||||
};
|
||||
|
||||
BottomScrubber.query = (url: string): QueryIdentifier<string> => ({
|
||||
path: ["video", url, "thumbnails.vtt"],
|
||||
parser: null!,
|
||||
options: {
|
||||
plainText: true,
|
||||
},
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user