From 3e78826658c7d2a4e9b3c1d73e63dacc1d39c361 Mon Sep 17 00:00:00 2001 From: Factiven Date: Sat, 12 Aug 2023 22:54:26 +0700 Subject: Update v3.9.3 - Merged Beta to Main (#51) * commit * update db * Update v3.9.1-beta-v3.1 * Update v3.9.1 * Fix watched progress not showing * Secure headers * Fix recently watched image * Update v3.9.2 > Added custom lists for AniList > Fixed episode listMode progress * Update db route * Fixed AniList * Fix next button on dub anime > video is playing sub anime instead dub * small adjusment for premid * fix eslint * small updates > added ability to remove episode from recently watched * Update v3.9.3 --- components/home/content.js | 126 ++++++++++++++++++++++++++++++++++++--------- 1 file changed, 101 insertions(+), 25 deletions(-) (limited to 'components/home/content.js') diff --git a/components/home/content.js b/components/home/content.js index f13c7a8..70f0e3f 100644 --- a/components/home/content.js +++ b/components/home/content.js @@ -5,6 +5,7 @@ import { MdChevronRight } from "react-icons/md"; import { ChevronRightIcon, ArrowRightCircleIcon, + XMarkIcon, } from "@heroicons/react/24/outline"; import { parseCookies } from "nookies"; @@ -12,6 +13,7 @@ import { parseCookies } from "nookies"; import { ChevronLeftIcon } from "@heroicons/react/20/solid"; import { ExclamationCircleIcon, PlayIcon } from "@heroicons/react/24/solid"; import { useRouter } from "next/router"; +import { toast } from "react-toastify"; export default function Content({ ids, @@ -20,6 +22,7 @@ export default function Content({ userData, og, userName, + setRemoved, }) { const router = useRouter(); @@ -139,10 +142,64 @@ export default function Content({ } }; + const removeItem = async (id) => { + if (userName) { + // remove from database + const res = await fetch(`/api/user/update/episode`, { + method: "DELETE", + headers: { + "Content-Type": "application/json", + }, + body: JSON.stringify({ + name: userName, + id: id, + }), + }); + const data = await res.json(); + + // remove from local storage + const artplayerSettings = + JSON.parse(localStorage.getItem("artplayer_settings")) || {}; + if (artplayerSettings[id]) { + delete artplayerSettings[id]; + localStorage.setItem( + "artplayer_settings", + JSON.stringify(artplayerSettings) + ); + } + + // update client + setRemoved(id); + + if (data?.message === "Episode deleted") { + toast.success("Episode removed from history", { + position: "bottom-right", + autoClose: 5000, + hideProgressBar: false, + closeOnClick: true, + draggable: true, + theme: "dark", + }); + } + } else { + const artplayerSettings = + JSON.parse(localStorage.getItem("artplayer_settings")) || {}; + if (artplayerSettings[id]) { + delete artplayerSettings[id]; + localStorage.setItem( + "artplayer_settings", + JSON.stringify(artplayerSettings) + ); + } + + setRemoved(id); + } + }; + return (
- {ids !== "recentlyWatched" ? slicedData?.map((anime) => { const progress = og?.find((i) => i.mediaId === anime.id); @@ -273,14 +329,27 @@ export default function Content({ if (prog > 90) prog = 100; return ( - -
+
+
removeItem(i.watchId)} + > + + + Remove from history + +
+
+
@@ -299,6 +368,7 @@ export default function Content({ width: `${prog}%`, }} /> + {i?.image && ( )} -
+ -
+ {/*

{i.title}

*/}

{" "} | Episode {i.episode}

-
- + +
); })} - {userData?.length >= 10 && section !== "Recommendations" && ( -
-
-

- More on {section} -

- + {userData?.filter((i) => i.aniId !== null)?.length >= 10 && + section !== "Recommendations" && ( +
+
+

+ More on {section} +

+ +
-
- )} + )} {filteredData?.length >= 10 && section !== "Recommendations" && (