From 658afe2c8f27612a4de7d30c8c363c18c170377a Mon Sep 17 00:00:00 2001 From: Jarmo Riikonen Date: Thu, 5 Jul 2018 11:59:53 +0300 Subject: [PATCH] Sticky hide #123 fix Working fix for "hide collection" bug. --- scripts/Actions/Explore.ts | 20 +++++++++++++++----- scripts/AnimeNotifier.ts | 15 ++++++++++++++- 2 files changed, 29 insertions(+), 6 deletions(-) diff --git a/scripts/Actions/Explore.ts b/scripts/Actions/Explore.ts index 271901a5..ddaeecbe 100644 --- a/scripts/Actions/Explore.ts +++ b/scripts/Actions/Explore.ts @@ -25,13 +25,23 @@ export function filterAnime(arn: AnimeNotifier, input: HTMLInputElement) { arn.diff(`${root.dataset.url}/${year}/${season}/${status}/${type}`) } -// Hides anime that are already in your list. -export function hideAddedAnime() { - for(let anime of findAll("anime-grid-cell")) { - if(anime.dataset.added === "true") { - anime.classList.toggle("anime-grid-cell-hide") +// 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" + } + + if(localStorage.hide === "true" || input.type === "submit"){ + for(let anime of findAll("anime-grid-cell")) { + if(anime.dataset.added === "true") { + anime.classList.toggle("anime-grid-cell-hide") + } } } + } // Hides anime that are not in your list. diff --git a/scripts/AnimeNotifier.ts b/scripts/AnimeNotifier.ts index ec86f409..70673072 100644 --- a/scripts/AnimeNotifier.ts +++ b/scripts/AnimeNotifier.ts @@ -13,6 +13,7 @@ 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 @@ -164,7 +165,8 @@ export default class AnimeNotifier { Promise.resolve().then(() => this.dragAndDrop()), Promise.resolve().then(() => this.colorStripes()), Promise.resolve().then(() => this.assignTooltipOffsets()), - Promise.resolve().then(() => this.countUp()) + Promise.resolve().then(() => this.countUp()), + Promise.resolve().then(() => this.hideMyAnimeInExplorer()) ]) // Apply page title @@ -473,6 +475,17 @@ export default class AnimeNotifier { } } + hideMyAnimeInExplorer() { + if(!this.app.currentPath.includes("/explore")){ + return + } + + const storage = localStorage.getItem("hide") + if(storage === "true"){ + hideAddedAnime() + } + } + markPlayingSoundTrack() { for(let element of findAll("soundtrack-play-area")) { if(element.dataset.soundtrackId === this.currentSoundTrackId) {