aboutsummaryrefslogtreecommitdiff
path: root/components
diff options
context:
space:
mode:
authorFactiven <[email protected]>2023-04-13 22:14:50 +0700
committerFactiven <[email protected]>2023-04-13 22:14:50 +0700
commit5007e48c8546d8138092039bf3cecc0b9904a407 (patch)
tree8b27c6fce4dcde5d21c04b65e1f2059924532cb4 /components
parentUpdate index.js (diff)
downloadmoopa-5007e48c8546d8138092039bf3cecc0b9904a407.tar.xz
moopa-5007e48c8546d8138092039bf3cecc0b9904a407.zip
Update 4th
Diffstat (limited to 'components')
-rw-r--r--components/videoPlayer.js18
1 files changed, 16 insertions, 2 deletions
diff --git a/components/videoPlayer.js b/components/videoPlayer.js
index e568772..092f53a 100644
--- a/components/videoPlayer.js
+++ b/components/videoPlayer.js
@@ -90,7 +90,7 @@ export default function VideoPlayer({
// use >= instead of >
markProgress(aniId, progress);
} else {
- console.log("Something went wrong");
+ return;
}
});
@@ -99,11 +99,25 @@ export default function VideoPlayer({
console.log("Video ended");
});
- art.on("destroy", () => {
+ art.on("destroy", async () => {
+ if (!session) return;
const lastPlayed = {
id: id,
time: art.currentTime,
};
+ const res = await fetch("/api/watched-episode", {
+ method: "POST",
+ body: JSON.stringify({
+ username: session?.user.name,
+ id: aniId,
+ newData: lastPlayed,
+ }),
+ headers: {
+ "Content-Type": "application/json",
+ },
+ });
+
+ console.log(res.status);
const title = titles;
const prevDataStr = localStorage.getItem("lastPlayed") || "[]";