mirror of
https://github.com/sussy-code/smov.git
synced 2024-12-20 14:37:43 +01:00
Fix bug where sometimes the wrong episode is played through episode selector
This commit is contained in:
parent
f30161fb1c
commit
51b7305799
3 changed files with 20 additions and 13 deletions
|
@ -1,5 +1,9 @@
|
|||
import { useInitializePlayer } from "@/components/player/hooks/useInitializePlayer";
|
||||
import { PlayerMeta, playerStatus } from "@/stores/player/slices/source";
|
||||
import {
|
||||
PlayerMeta,
|
||||
PlayerStatus,
|
||||
playerStatus,
|
||||
} from "@/stores/player/slices/source";
|
||||
import { usePlayerStore } from "@/stores/player/store";
|
||||
import { SourceSliceSource } from "@/stores/player/utils/qualities";
|
||||
import { ProgressMediaItem, useProgressStore } from "@/stores/progress";
|
||||
|
@ -37,10 +41,11 @@ export function usePlayer() {
|
|||
const progressStore = useProgressStore();
|
||||
|
||||
return {
|
||||
meta,
|
||||
reset,
|
||||
status,
|
||||
setMeta(m: PlayerMeta) {
|
||||
setMeta(m);
|
||||
setMeta(m: PlayerMeta, newStatus?: PlayerStatus) {
|
||||
setMeta(m, newStatus);
|
||||
},
|
||||
playMedia(source: SourceSliceSource, sourceId: string | null) {
|
||||
setSource(source, getProgress(progressStore.items, meta));
|
||||
|
|
|
@ -1,13 +1,16 @@
|
|||
import { useCallback, useMemo, useState } from "react";
|
||||
import { useCallback, useMemo } from "react";
|
||||
|
||||
import { DetailedMeta } from "@/backend/metadata/getmeta";
|
||||
import { MWMediaType } from "@/backend/metadata/types/mw";
|
||||
import { usePlayer } from "@/components/player/hooks/usePlayer";
|
||||
import { PlayerMeta, metaToScrapeMedia } from "@/stores/player/slices/source";
|
||||
import {
|
||||
PlayerMeta,
|
||||
metaToScrapeMedia,
|
||||
playerStatus,
|
||||
} from "@/stores/player/slices/source";
|
||||
|
||||
export function usePlayerMeta() {
|
||||
const { setMeta, setScrapeStatus } = usePlayer();
|
||||
const [meta, _setPlayerMeta] = useState<PlayerMeta | null>(null);
|
||||
const { meta, setMeta } = usePlayer();
|
||||
const scrapeMedia = useMemo(
|
||||
() => (meta ? metaToScrapeMedia(meta) : null),
|
||||
[meta]
|
||||
|
@ -15,11 +18,9 @@ export function usePlayerMeta() {
|
|||
|
||||
const setDirectMeta = useCallback(
|
||||
(m: PlayerMeta) => {
|
||||
_setPlayerMeta(m);
|
||||
setScrapeStatus();
|
||||
setMeta(m);
|
||||
setMeta(m, playerStatus.SCRAPING);
|
||||
},
|
||||
[_setPlayerMeta, setMeta, setScrapeStatus]
|
||||
[setMeta]
|
||||
);
|
||||
|
||||
const setPlayerMeta = useCallback(
|
||||
|
|
|
@ -60,7 +60,7 @@ export interface SourceSlice {
|
|||
setStatus(status: PlayerStatus): void;
|
||||
setSource(stream: SourceSliceSource, startAt: number): void;
|
||||
switchQuality(quality: SourceQuality): void;
|
||||
setMeta(meta: PlayerMeta): void;
|
||||
setMeta(meta: PlayerMeta, status?: PlayerStatus): void;
|
||||
setCaption(caption: Caption | null): void;
|
||||
setSourceId(id: string | null): void;
|
||||
enableAutomaticQuality(): void;
|
||||
|
@ -111,10 +111,11 @@ export const createSourceSlice: MakeSlice<SourceSlice> = (set, get) => ({
|
|||
s.status = status;
|
||||
});
|
||||
},
|
||||
setMeta(meta) {
|
||||
setMeta(meta, newStatus) {
|
||||
set((s) => {
|
||||
s.meta = meta;
|
||||
s.interface.hideNextEpisodeBtn = false;
|
||||
if (newStatus) s.status = newStatus;
|
||||
});
|
||||
},
|
||||
setCaption(caption) {
|
||||
|
|
Loading…
Reference in a new issue