Added hide method to work in genre and style fixes

This commit is contained in:
Jarmo Riikonen 2018-07-05 18:46:33 +03:00
parent 4ceb250fa9
commit d1ac2f1d9b
2 changed files with 13 additions and 14 deletions

View File

@ -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 // Hides anime that are already in your list. And "toggles" localStorage.hide if button is pressed
export function hideAddedAnime(arn?: AnimeNotifier, input?: HTMLInputElement) { export function hideAddedAnime(arn?: AnimeNotifier, input?: HTMLButtonElement) {
if (input != undefined && input.type == "submit") { if(input) {
if(localStorage.hide === "true") if(localStorage.getItem("hideAdded") === "true") {
localStorage.hide = "false" localStorage.setItem("hideAdded", "false")
else } else {
localStorage.hide = "true" 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")) { for(let anime of findAll("anime-grid-cell")) {
if(anime.dataset.added === "true") { if(anime.dataset.added === "true") {
anime.classList.toggle("anime-grid-cell-hide") anime.classList.toggle("anime-grid-cell-hide")

View File

@ -13,7 +13,6 @@ import { displayAiringDate, displayDate, displayTime } from "./DateView"
import { findAll, canUseWebP, requestIdleCallback, swapElements, delay } from "./Utils" import { findAll, canUseWebP, requestIdleCallback, swapElements, delay } from "./Utils"
import { checkNewVersionDelayed } from "./NewVersionCheck" import { checkNewVersionDelayed } from "./NewVersionCheck"
import * as actions from "./Actions" import * as actions from "./Actions"
import { hideAddedAnime } from "./Actions";
export default class AnimeNotifier { export default class AnimeNotifier {
app: Application app: Application
@ -166,7 +165,7 @@ export default class AnimeNotifier {
Promise.resolve().then(() => this.colorStripes()), Promise.resolve().then(() => this.colorStripes()),
Promise.resolve().then(() => this.assignTooltipOffsets()), Promise.resolve().then(() => this.assignTooltipOffsets()),
Promise.resolve().then(() => this.countUp()), Promise.resolve().then(() => this.countUp()),
Promise.resolve().then(() => this.hideMyAnimeInExplorer()) Promise.resolve().then(() => this.hideAddedAnime())
]) ])
// Apply page title // Apply page title
@ -476,14 +475,13 @@ export default class AnimeNotifier {
} }
// Hides user anime automatically if localStorage.hide is true // Hides user anime automatically if localStorage.hide is true
hideMyAnimeInExplorer() { hideAddedAnime() {
if(!this.app.currentPath.includes("/explore")){ if(!this.app.currentPath.includes("/explore") && !this.app.currentPath.includes("/genre")) {
return return
} }
const storage = localStorage.getItem("hide") if(localStorage.getItem("hideAdded") === "true") {
if(storage === "true"){ actions.hideAddedAnime()
hideAddedAnime()
} }
} }