Skip to content

Commit

Permalink
feat: improve media types
Browse files Browse the repository at this point in the history
  • Loading branch information
ThaUnknown committed Feb 6, 2024
1 parent 712717e commit 00e3989
Show file tree
Hide file tree
Showing 6 changed files with 60 additions and 49 deletions.
2 changes: 1 addition & 1 deletion common/components/cards/EpisodeCard.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
export let data
let preview = false
/** @type {import('@/modules/al.d.ts').Media | null} */
const media = data.media
const episodeThumbnail = ((!media?.mediaListEntry?.status || !(media.mediaListEntry.status === 'CURRENT' && media.mediaListEntry.progress < data.episode)) && data.episodeData?.image) || media?.bannerImage || media?.coverImage.extraLarge || ' '
Expand Down
2 changes: 1 addition & 1 deletion common/components/cards/EpisodePreviewCard.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import { since } from '@/modules/util'
import { liveAnimeEpisodeProgress } from '@/modules/animeprogress.js'
export let data
/** @type {import('@/modules/al.d.ts').Media | null} */
const media = data.media
const episodeThumbnail = ((!media?.mediaListEntry?.status || !(media.mediaListEntry.status === 'CURRENT' && media.mediaListEntry.progress < data.episode)) && data.episodeData?.image) || media?.bannerImage || media?.coverImage.extraLarge || ' '
Expand Down
1 change: 1 addition & 0 deletions common/components/cards/FullCard.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import { click } from '@/modules/click.js'
import { countdown } from '@/modules/util.js'
import { page } from '@/App.svelte'
/** @type {import('@/modules/al.d.ts').Media} */
export let media
const view = getContext('view')
Expand Down
4 changes: 4 additions & 0 deletions common/components/cards/PreviewCard.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,14 @@
import { formatMap, setStatus, playMedia } from '@/modules/anime.js'
import { anilistClient } from '@/modules/anilist.js'
import { click } from '@/modules/click.js'
/** @type {import('@/modules/al.d.ts').Media} */
export let media
let hide = true
/**
* @param {import('@/modules/al.d.ts').Media} media
*/
function getPlayButtonText (media) {
if (media.mediaListEntry) {
const { status, progress } = media.mediaListEntry
Expand Down
2 changes: 1 addition & 1 deletion common/components/cards/SmallCard.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import { countdown } from '@/modules/util.js'
import { page } from '@/App.svelte'
/** @type {import('@/modules/al.d.ts').Media} */
export let media
let preview = false
Expand Down
98 changes: 52 additions & 46 deletions common/modules/al.d.ts
Original file line number Diff line number Diff line change
@@ -1,64 +1,70 @@
export type Media = {
id: number
title: {
romaji: string
english: string
native: string
romaji?: string
english?: string
native?: string
userPreferred: string
}
description: string
season: string
seasonYear: string
description?: string
season?: string
seasonYear?: string
format: string
status: string
episodes: number
duration: number
averageScore: number
genres: string[]
episodes?: number
duration?: number
averageScore?: number
genres?: string[]
isFavourite: boolean
coverImage: {
coverImage?: {
extraLarge: string
large: string
color: string
medium: string
}
source: string
countryOfOrigin: string
isAdult: boolean
bannerImage: string
synonyms: string[]
nextAiringEpisode: {
source?: string
countryOfOrigin?: string
isAdult?: boolean
bannerImage?: string
synonyms?: string[]
nextAiringEpisode?: {
episode: number
airingAt: number
}
startDate: {
startDate?: {
year: number
month: number
day: number
month?: number
day?: number
}
trailer: {
trailer?: {
id: string
site: string
}
streamingEpisodes: {
streamingEpisodes?: {
title: string
thumbnail: string
}[]
mediaListEntry: {
mediaListEntry?: {
id: number
progress: number
repeat: number
status: string
cusomLists: string[]
score: number
status?: string
customLists?: string[]
score?: number
}
studios: {
studios?: {
edges: {
node: {
name: string
}
}[]
}
relations: {
airingSchedule?: {
nodes?: {
episode: number
airingAt: number
}[]
}
relations?: {
edges: {
relationType: string
node: {
Expand All @@ -68,33 +74,33 @@ export type Media = {
}
type: string
status: string
format: string
episodes: number
synonyms: string[]
season: string
seasonYear: number
startDate: {
format?: string
episodes?: number
synonyms?: string[]
season?: string
seasonYear?: number
startDate?: {
year: number
month: number
day: number
month?: number
day?: number
}
endDate: {
endDate?: {
year: number
month: number
day: number
}
}
}[]
}
recommendations: {
edges: {
recommendations?: {
edges?: {
node: {
media: {
id: number
title: {
userPreferred: string
}
coverImage: {
coverImage?: {
medium: string
}
}
Expand Down Expand Up @@ -125,10 +131,10 @@ export type MediaListCollection = {
mediaListEntry: {
progress: number
}
nextAiringEpisode: {
nextAiringEpisode?: {
episode: number
}
relations: {
relations?: {
edges: {
relationType: string
node: {
Expand All @@ -147,9 +153,9 @@ export type Viewer = {
}
name: string
id: number
mediaListOptions: {
animeList: {
customLists: string[]
mediaListOptions?: {
animeList?: {
customLists?: string[]
}
}
}
Expand Down

0 comments on commit 00e3989

Please sign in to comment.