aboutsummaryrefslogtreecommitdiff
path: root/src/lib/Data/AniList/media.ts
diff options
context:
space:
mode:
authorFuwn <[email protected]>2026-05-29 23:44:08 +0000
committerFuwn <[email protected]>2026-05-29 23:44:08 +0000
commit49879c43ebd9f36ec19f4c02fa2b121314126286 (patch)
treebbf1e42eba5996640ffcc7f44d07245cdf2c5e5c /src/lib/Data/AniList/media.ts
parentchore(biome): scope linting to remove Svelte false positives (diff)
downloaddue.moe-49879c43ebd9f36ec19f4c02fa2b121314126286.tar.xz
due.moe-49879c43ebd9f36ec19f4c02fa2b121314126286.zip
style: apply biome autofixes and resolve remaining lint findingsHEADmain
Auto-fixed cosmetic findings (import ordering, obj["k"]->obj.k, optional chaining, template literals, Date.now, parseInt radix, useless ternaries/ switch cases). Resolved the non-autofixable rest by hand: - Senpy: static-only class -> object literal (no this/static reliance). - app.html: var global shim -> window.global = window (keeps the shim, drops the unused-var flag). - biome-ignore with rationale for the logout document.cookie clear and the holodule scrape non-null assertion. Verified: biome check 0 diagnostics, svelte-check 0/0, 24/24 unit tests.
Diffstat (limited to 'src/lib/Data/AniList/media.ts')
-rw-r--r--src/lib/Data/AniList/media.ts51
1 files changed, 24 insertions, 27 deletions
diff --git a/src/lib/Data/AniList/media.ts b/src/lib/Data/AniList/media.ts
index 0a83dda6..d38d073e 100644
--- a/src/lib/Data/AniList/media.ts
+++ b/src/lib/Data/AniList/media.ts
@@ -1,16 +1,16 @@
+import localforage from "localforage";
+import { get } from "svelte/store";
import { browser } from "$app/environment";
import type { AniListAuthorisation } from "$lib/Data/AniList/identity";
import { parseJsonStringOrDefault } from "$lib/Effect/json";
-import type { UserIdentity } from "./identity";
+import { options as getOptions, type Options } from "$lib/Notification/options";
import anime from "$stores/anime";
+import lastPruneTimes from "$stores/lastPruneTimes";
+import locale from "$stores/locale";
import manga from "$stores/manga";
import settings from "$stores/settings";
-import lastPruneTimes from "$stores/lastPruneTimes";
-import { options as getOptions, type Options } from "$lib/Notification/options";
+import type { UserIdentity } from "./identity";
import type { PrequelRelation, PrequelRelations } from "./prequels";
-import localforage from "localforage";
-import locale from "$stores/locale";
-import { get } from "svelte/store";
export enum Type {
Anime,
@@ -340,21 +340,20 @@ export const mediaListCollection = async (
currentLastPruneAt = hydratedInputs.currentLastPruneAt;
if (String(currentLastPruneAt) === "") {
- if (type === Type.Anime)
- lastPruneTimes.setKey("anime", new Date().getTime());
- else lastPruneTimes.setKey("manga", new Date().getTime());
+ if (type === Type.Anime) lastPruneTimes.setKey("anime", Date.now());
+ else lastPruneTimes.setKey("manga", Date.now());
} else {
if (
- (new Date().getTime() - Number(currentLastPruneAt)) / 1000 / 60 >
+ (Date.now() - Number(currentLastPruneAt)) / 1000 / 60 >
Number(currentCacheMinutes) ||
options.forcePrune
) {
if (type === Type.Anime) {
- lastPruneTimes.setKey("anime", new Date().getTime());
+ lastPruneTimes.setKey("anime", Date.now());
if (usesSharedMediaStore(options)) anime.set("");
} else {
- lastPruneTimes.setKey("manga", new Date().getTime());
+ lastPruneTimes.setKey("manga", Date.now());
if (usesSharedMediaStore(options)) manga.set("");
}
@@ -387,14 +386,14 @@ export const mediaListCollection = async (
).json();
if (
- !userIdResponse["data"] ||
- !userIdResponse["data"]["MediaListCollection"] ||
- !userIdResponse["data"]["MediaListCollection"]["lists"]
+ !userIdResponse.data ||
+ !userIdResponse.data.MediaListCollection ||
+ !userIdResponse.data.MediaListCollection.lists
)
return [];
const flattened = flattenLists(
- userIdResponse["data"]["MediaListCollection"]["lists"],
+ userIdResponse.data.MediaListCollection.lists,
options.all,
);
@@ -518,15 +517,13 @@ export const recentMediaActivities = async (
).json();
const guesses: number[] = [];
- activities["data"]["Page"]["activities"].forEach(
- (activity: { progress: string }) => {
- if (activity.progress !== null) {
- const progress = Number((activity.progress.match(/\d+$/) || [0])[0]);
+ activities.data.Page.activities.forEach((activity: { progress: string }) => {
+ if (activity.progress !== null) {
+ const progress = Number((activity.progress.match(/\d+$/) || [0])[0]);
- if (progress !== 65535) guesses.push(progress);
- }
- },
- );
+ if (progress !== 65535) guesses.push(progress);
+ }
+ });
guesses.sort((a, b) => b - a);
if (guesses.length) {
@@ -588,8 +585,8 @@ export const recentMediaActivities = async (
// }
// if (activities['data']['MediaList']['progress'] !== null) {
- if (activities["data"]["MediaList"]["progress"] > bestGuess)
- bestGuess = activities["data"]["MediaList"]["progress"];
+ if (activities.data.MediaList.progress > bestGuess)
+ bestGuess = activities.data.MediaList.progress;
// }
return Math.round(bestGuess);
@@ -614,7 +611,7 @@ export const mediaCover = async (id: number) =>
}),
})
).json()
- )["data"]["Media"]["coverImage"]["extraLarge"];
+ ).data.Media.coverImage.extraLarge;
export interface UnwatchedRelationMap {
media: Media;