Sticky hide #123 fix

Working fix for "hide collection" bug.
This commit is contained in:
Jarmo Riikonen 2018-07-05 11:59:53 +03:00
parent dd39a8bfd9
commit 658afe2c8f
2 changed files with 29 additions and 6 deletions

View File

@ -25,8 +25,16 @@ export function filterAnime(arn: AnimeNotifier, input: HTMLInputElement) {
arn.diff(`${root.dataset.url}/${year}/${season}/${status}/${type}`) arn.diff(`${root.dataset.url}/${year}/${season}/${status}/${type}`)
} }
// Hides anime that are already in your list. // Hides anime that are already in your list. And "toggles" localStorage.hide if button is pressed
export function hideAddedAnime() { 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")) { 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")
@ -34,6 +42,8 @@ export function hideAddedAnime() {
} }
} }
}
// Hides anime that are not in your list. // Hides anime that are not in your list.
export function calendarShowAddedAnimeOnly() { export function calendarShowAddedAnimeOnly() {
for(let anime of findAll("calendar-entry")) { for(let anime of findAll("calendar-entry")) {

View File

@ -13,6 +13,7 @@ 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
@ -164,7 +165,8 @@ export default class AnimeNotifier {
Promise.resolve().then(() => this.dragAndDrop()), Promise.resolve().then(() => this.dragAndDrop()),
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())
]) ])
// Apply page title // 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() { markPlayingSoundTrack() {
for(let element of findAll("soundtrack-play-area")) { for(let element of findAll("soundtrack-play-area")) {
if(element.dataset.soundtrackId === this.currentSoundTrackId) { if(element.dataset.soundtrackId === this.currentSoundTrackId) {