diff --git a/scripts/Actions/Explore.ts b/scripts/Actions/Explore.ts index f14c80ca..dfa759c4 100644 --- a/scripts/Actions/Explore.ts +++ b/scripts/Actions/Explore.ts @@ -26,15 +26,16 @@ export function filterAnime(arn: AnimeNotifier, input: HTMLInputElement) { } // Hides anime that are already in your list. And "toggles" localStorage.hide if button is pressed -export function hideAddedAnime(arn?: AnimeNotifier, input?: HTMLInputElement) { - if (input != undefined && input.type == "submit") { - if(localStorage.hide === "true") - localStorage.hide = "false" - else - localStorage.hide = "true" +export function hideAddedAnime(arn?: AnimeNotifier, input?: HTMLButtonElement) { + if(input) { + if(localStorage.getItem("hideAdded") === "true") { + localStorage.setItem("hideAdded", "false") + } else { + localStorage.setItem("hideAdded", "true") + } } - if(localStorage.hide === "true" || input.type === "submit"){ + if(localStorage.getItem("hideAdded") === "true" || input.type === "submit") { for(let anime of findAll("anime-grid-cell")) { if(anime.dataset.added === "true") { anime.classList.toggle("anime-grid-cell-hide") diff --git a/scripts/AnimeNotifier.ts b/scripts/AnimeNotifier.ts index 7b4a6101..e8286c93 100644 --- a/scripts/AnimeNotifier.ts +++ b/scripts/AnimeNotifier.ts @@ -13,7 +13,6 @@ import { displayAiringDate, displayDate, displayTime } from "./DateView" import { findAll, canUseWebP, requestIdleCallback, swapElements, delay } from "./Utils" import { checkNewVersionDelayed } from "./NewVersionCheck" import * as actions from "./Actions" -import { hideAddedAnime } from "./Actions"; export default class AnimeNotifier { app: Application @@ -166,7 +165,7 @@ export default class AnimeNotifier { Promise.resolve().then(() => this.colorStripes()), Promise.resolve().then(() => this.assignTooltipOffsets()), Promise.resolve().then(() => this.countUp()), - Promise.resolve().then(() => this.hideMyAnimeInExplorer()) + Promise.resolve().then(() => this.hideAddedAnime()) ]) // Apply page title @@ -476,14 +475,13 @@ export default class AnimeNotifier { } // Hides user anime automatically if localStorage.hide is true - hideMyAnimeInExplorer() { - if(!this.app.currentPath.includes("/explore")){ + hideAddedAnime() { + if(!this.app.currentPath.includes("/explore") && !this.app.currentPath.includes("/genre")) { return } - const storage = localStorage.getItem("hide") - if(storage === "true"){ - hideAddedAnime() + if(localStorage.getItem("hideAdded") === "true") { + actions.hideAddedAnime() } }