Merge pull request #172 from Amatrelan/sticky-hide

Persistent hide #123
This commit is contained in:
Eduard Urbach 2018-07-06 01:30:49 +09:00 committed by GitHub
commit 9c67a51fb4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 28 additions and 6 deletions

View File

@ -25,14 +25,24 @@ 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() {
// 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("hide-added-anime") === "true") {
localStorage.setItem("hide-added-anime", "false")
} else {
localStorage.setItem("hide-added-anime", "true")
}
}
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")
}
}
}
}
// Hides anime that are not in your list.
export function calendarShowAddedAnimeOnly() {

View File

@ -164,7 +164,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.hideAddedAnime())
])
// Apply page title
@ -473,6 +474,17 @@ export default class AnimeNotifier {
}
}
// Hides user anime automatically if localStorage.hide is true
hideAddedAnime() {
if(!this.app.currentPath.includes("/explore") && !this.app.currentPath.includes("/genre")) {
return
}
if(localStorage.getItem("hide-added-anime") === "true") {
actions.hideAddedAnime()
}
}
markPlayingSoundTrack() {
for(let element of findAll("soundtrack-play-area")) {
if(element.dataset.soundtrackId === this.currentSoundTrackId) {