mirror of
https://github.com/Radiquum/AniX.git
synced 2025-04-07 00:34:41 +00:00
fix: episode doesn't save to the history
This commit is contained in:
parent
8bab85ddc1
commit
9442063f57
1 changed files with 7 additions and 16 deletions
|
@ -9,7 +9,7 @@ import { useState, useEffect } from "react";
|
||||||
const DropdownTheme = {
|
const DropdownTheme = {
|
||||||
floating: {
|
floating: {
|
||||||
target:
|
target:
|
||||||
"w-full md:w-[256px] bg-blue-600 enabled:hover:bg-blue-700 focus:ring-4 focus:outline-none focus:ring-blue-300 text-center dark:bg-blue-600 dark:hover:bg-blue-700 dark:focus:ring-blue-800",
|
"w-full md:min-w-[256px] md:w-fit bg-blue-600 enabled:hover:bg-blue-700 focus:ring-4 focus:outline-none focus:ring-blue-300 text-center dark:bg-blue-600 dark:hover:bg-blue-700 dark:focus:ring-blue-800",
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -39,7 +39,6 @@ export const ReleasePlayer = (props: { id: number }) => {
|
||||||
const [selectedSource, setSelectedSource] = useState(null);
|
const [selectedSource, setSelectedSource] = useState(null);
|
||||||
const [episodeInfo, setEpisodeInfo] = useState(null);
|
const [episodeInfo, setEpisodeInfo] = useState(null);
|
||||||
const [selectedEpisode, setSelectedEpisode] = useState(null);
|
const [selectedEpisode, setSelectedEpisode] = useState(null);
|
||||||
const [isFirstLoad, setIsFirstLoad] = useState(true);
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
async function _fetchInfo() {
|
async function _fetchInfo() {
|
||||||
|
@ -84,25 +83,16 @@ export const ReleasePlayer = (props: { id: number }) => {
|
||||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
}, [selectedSource, token]);
|
}, [selectedSource, token]);
|
||||||
|
|
||||||
useEffect(() => {
|
async function _addToHistory(episode: any) {
|
||||||
async function _fetchInfo() {
|
if (episode && token) {
|
||||||
_fetch(
|
_fetch(
|
||||||
`${ENDPOINTS.statistic.addHistory}/${props.id}/${selectedVoiceover.id}/${selectedSource.id}?token=${token}`
|
`${ENDPOINTS.statistic.addHistory}/${props.id}/${selectedSource.id}/${episode.position}?token=${token}`
|
||||||
);
|
);
|
||||||
_fetch(
|
_fetch(
|
||||||
`${ENDPOINTS.statistic.markWatched}/${props.id}/${selectedVoiceover.id}/${selectedSource.id}?token=${token}`
|
`${ENDPOINTS.statistic.markWatched}/${props.id}/${selectedSource.id}/${episode.position}?token=${token}`
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if (selectedEpisode && !isFirstLoad && token) {
|
}
|
||||||
_fetchInfo();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isFirstLoad) {
|
|
||||||
setIsFirstLoad(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
||||||
}, [selectedEpisode]);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Card>
|
<Card>
|
||||||
|
@ -160,6 +150,7 @@ export const ReleasePlayer = (props: { id: number }) => {
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
setSelectedEpisode(episode);
|
setSelectedEpisode(episode);
|
||||||
episode.is_watched = true;
|
episode.is_watched = true;
|
||||||
|
_addToHistory(episode);
|
||||||
}}
|
}}
|
||||||
disabled={selectedEpisode.position === episode.position}
|
disabled={selectedEpisode.position === episode.position}
|
||||||
>
|
>
|
||||||
|
|
Loading…
Add table
Reference in a new issue