From 658afe2c8f27612a4de7d30c8c363c18c170377a Mon Sep 17 00:00:00 2001 From: Jarmo Riikonen Date: Thu, 5 Jul 2018 11:59:53 +0300 Subject: [PATCH 1/4] 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) { From 4ceb250fa990e5770509d47a5d5acdbb85be30ea Mon Sep 17 00:00:00 2001 From: Jarmo Riikonen Date: Thu, 5 Jul 2018 13:23:48 +0300 Subject: [PATCH 2/4] Forgot add comment for hideMyAnimeInExplorer and one empty line --- scripts/Actions/Explore.ts | 1 - scripts/AnimeNotifier.ts | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/Actions/Explore.ts b/scripts/Actions/Explore.ts index ddaeecbe..f14c80ca 100644 --- a/scripts/Actions/Explore.ts +++ b/scripts/Actions/Explore.ts @@ -41,7 +41,6 @@ export function hideAddedAnime(arn?: AnimeNotifier, input?: HTMLInputElement) { } } } - } // Hides anime that are not in your list. diff --git a/scripts/AnimeNotifier.ts b/scripts/AnimeNotifier.ts index 70673072..7b4a6101 100644 --- a/scripts/AnimeNotifier.ts +++ b/scripts/AnimeNotifier.ts @@ -475,6 +475,7 @@ export default class AnimeNotifier { } } + // Hides user anime automatically if localStorage.hide is true hideMyAnimeInExplorer() { if(!this.app.currentPath.includes("/explore")){ return From d1ac2f1d9bc3020a650a49e27766f9c7381944b7 Mon Sep 17 00:00:00 2001 From: Jarmo Riikonen Date: Thu, 5 Jul 2018 18:46:33 +0300 Subject: [PATCH 3/4] Added hide method to work in genre and style fixes --- scripts/Actions/Explore.ts | 15 ++++++++------- scripts/AnimeNotifier.ts | 12 +++++------- 2 files changed, 13 insertions(+), 14 deletions(-) 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() } } From b264d7b28c2651a25079ef784c573fdf73988ffa Mon Sep 17 00:00:00 2001 From: Jarmo Riikonen Date: Thu, 5 Jul 2018 19:14:20 +0300 Subject: [PATCH 4/4] Better names --- scripts/Actions/Explore.ts | 8 ++++---- scripts/AnimeNotifier.ts | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/scripts/Actions/Explore.ts b/scripts/Actions/Explore.ts index dfa759c4..7278876f 100644 --- a/scripts/Actions/Explore.ts +++ b/scripts/Actions/Explore.ts @@ -28,14 +28,14 @@ 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?: HTMLButtonElement) { if(input) { - if(localStorage.getItem("hideAdded") === "true") { - localStorage.setItem("hideAdded", "false") + if(localStorage.getItem("hide-added-anime") === "true") { + localStorage.setItem("hide-added-anime", "false") } else { - localStorage.setItem("hideAdded", "true") + localStorage.setItem("hide-added-anime", "true") } } - if(localStorage.getItem("hideAdded") === "true" || input.type === "submit") { + if(input || localStorage.getItem("hide-added-anime") === "true") { 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 e8286c93..4b3563ef 100644 --- a/scripts/AnimeNotifier.ts +++ b/scripts/AnimeNotifier.ts @@ -480,7 +480,7 @@ export default class AnimeNotifier { return } - if(localStorage.getItem("hideAdded") === "true") { + if(localStorage.getItem("hide-added-anime") === "true") { actions.hideAddedAnime() } }