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
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")

View File

@ -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()
}
}