The show/hide anime not in my list state is now saved

This commit is contained in:
Soulcramer 2019-03-03 17:45:44 +01:00
parent 86170f4604
commit a35a77f0c5
2 changed files with 22 additions and 27 deletions

View File

@ -4,10 +4,7 @@ component Calendar(days []*utils.CalendarDay, user *arn.User)
.corner-buttons .corner-buttons
if user != nil if user != nil
button.action(data-trigger="click", data-action="calendarShowAddedAnimeOnly", data-api="/api/settings/" + user.ID, title="Show anime in my collection") button.action(data-trigger="click", data-action="calendarShowAddedAnimeOnly", data-api="/api/settings/" + user.ID, title="Show anime in my collection")
RawIcon("eye") RawIcon("eye-slash")
else
button.action(data-trigger="click", data-action="calendarShowAddedAnimeOnly", title="Show anime in my collection")
RawIcon("eye")
.week .week
each day in days each day in days
@ -18,19 +15,17 @@ component Calendar(days []*utils.CalendarDay, user *arn.User)
CalendarEntry(day, entry, user) CalendarEntry(day, entry, user)
component CalendarEntry(day *utils.CalendarDay, entry *utils.CalendarEntry, user *arn.User) component CalendarEntry(day *utils.CalendarDay, entry *utils.CalendarEntry, user *arn.User)
if user!= nil && user.Settings().CalendarSettings.ShowUserList == true if user != nil && user.Settings().CalendarSettings.ShowUserList == false && !entry.Added
a.calendar-entry.mountable(href=entry.Anime.Link(), data-mountable-type=day.Name, data-added=entry.Added)
img.calendar-entry-image.lazy(data-src=entry.Anime.ImageLink("small"), data-webp="true", data-color=entry.Anime.AverageColor(), alt=entry.Anime.Title.ByUser(user))
.calendar-entry-info
.calendar-entry-title= entry.Anime.Title.ByUser(user)
.calendar-entry-time-and-episode
.calendar-entry-time.utc-date-absolute(data-date=entry.Episode.AiringDate.Start)
.calendar-entry-episode= "Ep: " + strconv.Itoa(entry.Episode.Number)
else
a.calendar-entry.hidden.mountable(href=entry.Anime.Link(), data-mountable-type=day.Name, data-added=entry.Added) a.calendar-entry.hidden.mountable(href=entry.Anime.Link(), data-mountable-type=day.Name, data-added=entry.Added)
img.calendar-entry-image.lazy(data-src=entry.Anime.ImageLink("small"), data-webp="true", data-color=entry.Anime.AverageColor(), alt=entry.Anime.Title.ByUser(user)) CalendarView(day, entry, user)
.calendar-entry-info else
.calendar-entry-title= entry.Anime.Title.ByUser(user) a.calendar-entry.mountable(href=entry.Anime.Link(), data-mountable-type=day.Name, data-added=entry.Added)
.calendar-entry-time-and-episode CalendarView(day, entry, user)
.calendar-entry-time.utc-date-absolute(data-date=entry.Episode.AiringDate.Start)
.calendar-entry-episode= "Ep: " + strconv.Itoa(entry.Episode.Number) component CalendarView(day *utils.CalendarDay, entry *utils.CalendarEntry, user *arn.User)
img.calendar-entry-image.lazy(data-src=entry.Anime.ImageLink("small"), data-webp="true", data-color=entry.Anime.AverageColor(), alt=entry.Anime.Title.ByUser(user))
.calendar-entry-info
.calendar-entry-title= entry.Anime.Title.ByUser(user)
.calendar-entry-time-and-episode
.calendar-entry-time.utc-date-absolute(data-date=entry.Episode.AiringDate.Start)
.calendar-entry-episode= "Ep: " + strconv.Itoa(entry.Episode.Number)

View File

@ -1,5 +1,5 @@
import AnimeNotifier from "../AnimeNotifier" import AnimeNotifier from "../AnimeNotifier"
import {findAll} from "scripts/Utils" import { findAll } from "scripts/Utils"
// Filter anime on explore page // Filter anime on explore page
export function filterAnime(arn: AnimeNotifier, input: HTMLInputElement) { export function filterAnime(arn: AnimeNotifier, input: HTMLInputElement) {
@ -10,7 +10,7 @@ export function filterAnime(arn: AnimeNotifier, input: HTMLInputElement) {
let elementStatus = document.getElementById("filter-status") as HTMLSelectElement let elementStatus = document.getElementById("filter-status") as HTMLSelectElement
let elementType = document.getElementById("filter-type") as HTMLSelectElement let elementType = document.getElementById("filter-type") as HTMLSelectElement
for (let element of findAll("anime-grid-image")) { for(let element of findAll("anime-grid-image")) {
let img = element as HTMLImageElement let img = element as HTMLImageElement
img.src = arn.emptyPixel() img.src = arn.emptyPixel()
img.classList.remove("element-found") img.classList.remove("element-found")
@ -32,8 +32,8 @@ export function toggleHideAddedAnime() {
// Hides anime that are already in your list. // Hides anime that are already in your list.
export function hideAddedAnime() { export function hideAddedAnime() {
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") {
continue continue
} }
@ -43,14 +43,14 @@ export function hideAddedAnime() {
// Hides anime that are not in your list. // Hides anime that are not in your list.
export function calendarShowAddedAnimeOnly(arn: AnimeNotifier, element: HTMLInputElement) { export function calendarShowAddedAnimeOnly(arn: AnimeNotifier, element: HTMLInputElement) {
for (let anime of findAll("calendar-entry")) { for(let anime of findAll("calendar-entry")) {
if (anime.dataset.added === "false") { if(anime.dataset.added === "false") {
anime.classList.toggle("hidden") anime.classList.toggle("hidden")
} }
} }
const anime = document.getElementsByClassName("calendar-entry").item(0) const showUserList = !Array.from(document.getElementsByClassName("calendar-entry"))
const showUserList = !anime.classList.contains("hidden") .some(value => value.classList.contains("hidden"));
let obj = { let obj = {
"CalendarSettings.ShowUserList": showUserList "CalendarSettings.ShowUserList": showUserList