From da5197b3479174998a10f66f12f230e2fc9cf76a Mon Sep 17 00:00:00 2001 From: hoangvu12 Date: Tue, 21 Nov 2023 23:26:26 +0700 Subject: [PATCH] feat: recently watched screen --- src/gql/gql.ts | 32 +- src/gql/graphql.ts | 1424 ++++++++++------- src/hooks/use-watched.tsx | 169 ++ src/navigation/anime-navigator.tsx | 7 + src/screens/anime/components/watched-list.tsx | 165 +- src/screens/anime/recently-watched/screen.tsx | 78 + 6 files changed, 1108 insertions(+), 767 deletions(-) create mode 100644 src/hooks/use-watched.tsx create mode 100644 src/screens/anime/recently-watched/screen.tsx diff --git a/src/gql/gql.ts b/src/gql/gql.ts index efc338c..304b7c9 100644 --- a/src/gql/gql.ts +++ b/src/gql/gql.ts @@ -13,6 +13,10 @@ import { TypedDocumentNode as DocumentNode } from '@graphql-typed-document-node/ * Therefore it is highly recommended to use the babel or swc plugin for production. */ const documents = { + '\n query WatchedList($id_in: [Int], $perPage: Int = 10, $page: Int = 1) {\n Page(page: $page, perPage: $perPage) {\n pageInfo {\n total\n perPage\n currentPage\n lastPage\n hasNextPage\n }\n\n media(id_in: $id_in) {\n id\n ...WatchCard\n ...CardMedia\n }\n }\n }\n': + types.WatchedListDocument, + '\n query AuthWatchedList(\n $userId: Int\n $userName: String\n $status_in: [MediaListStatus]\n $type: MediaType\n $sort: [MediaListSort]\n $perPage: Int = 10\n $page: Int = 1\n ) {\n Page(page: $page, perPage: $perPage) {\n pageInfo {\n total\n perPage\n currentPage\n lastPage\n hasNextPage\n }\n\n mediaList(\n userId: $userId\n userName: $userName\n status_in: $status_in\n type: $type\n sort: $sort\n ) {\n progress\n media {\n id\n ...WatchCard\n ...CardMedia\n }\n }\n }\n }\n': + types.AuthWatchedListDocument, '\n query Viewer {\n Viewer {\n name\n avatar {\n medium\n }\n id\n }\n }\n': types.ViewerDocument, '\n mutation SaveMediaListEntry(\n $id: Int\n $mediaId: Int\n $status: MediaListStatus\n $score: Float\n $scoreRaw: Int\n $progress: Int\n $progressVolumes: Int\n $repeat: Int\n $priority: Int\n $private: Boolean\n $notes: String\n $hiddenFromStatusLists: Boolean\n $customLists: [String]\n $advancedScores: [Float]\n $startedAt: FuzzyDateInput\n $completedAt: FuzzyDateInput\n ) {\n SaveMediaListEntry(\n id: $id\n mediaId: $mediaId\n status: $status\n score: $score\n scoreRaw: $scoreRaw\n progress: $progress\n progressVolumes: $progressVolumes\n repeat: $repeat\n priority: $priority\n private: $private\n notes: $notes\n hiddenFromStatusLists: $hiddenFromStatusLists\n customLists: $customLists\n advancedScores: $advancedScores\n startedAt: $startedAt\n completedAt: $completedAt\n ) {\n progress\n score(format: POINT_10_DECIMAL)\n status\n }\n }\n': @@ -25,10 +29,6 @@ const documents = { types.UpcomingNextSeasonDocument, '\n fragment WatchCard on Media {\n id\n title {\n userPreferred\n }\n coverImage {\n large\n }\n bannerImage\n ...MediaUnitStatsMedia\n }\n': types.WatchCardFragmentDoc, - '\n query WatchedList($id_in: [Int]) {\n Page(page: 1, perPage: 10) {\n media(id_in: $id_in) {\n id\n ...WatchCard\n }\n }\n }\n': - types.WatchedListDocument, - '\n query AuthWatchedList(\n $userId: Int\n $userName: String\n $status_in: [MediaListStatus]\n $type: MediaType\n $sort: [MediaListSort]\n ) {\n Page(page: 1, perPage: 10) {\n mediaList(\n userId: $userId\n userName: $userName\n status_in: $status_in\n type: $type\n sort: $sort\n ) {\n progress\n media {\n id\n ...WatchCard\n }\n }\n }\n }\n': - types.AuthWatchedListDocument, '\n fragment DetailsHeaderMedia on Media {\n title {\n userPreferred\n }\n bannerImage\n genres\n favourites\n averageScore\n seasonYear\n nextAiringEpisode {\n airingAt\n episode\n }\n coverImage {\n large\n }\n }\n': types.DetailsHeaderMediaFragmentDoc, '\n query InfoDetailsScreen($id: Int) {\n Media(id: $id) {\n title {\n userPreferred\n }\n ...DetailsHeaderMedia\n ...InfoScreenMedia\n ...EpisodeContainer\n }\n }\n': @@ -93,6 +93,18 @@ const documents = { */ export function graphql(source: string): unknown; +/** + * The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients. + */ +export function graphql( + source: '\n query WatchedList($id_in: [Int], $perPage: Int = 10, $page: Int = 1) {\n Page(page: $page, perPage: $perPage) {\n pageInfo {\n total\n perPage\n currentPage\n lastPage\n hasNextPage\n }\n\n media(id_in: $id_in) {\n id\n ...WatchCard\n ...CardMedia\n }\n }\n }\n' +): (typeof documents)['\n query WatchedList($id_in: [Int], $perPage: Int = 10, $page: Int = 1) {\n Page(page: $page, perPage: $perPage) {\n pageInfo {\n total\n perPage\n currentPage\n lastPage\n hasNextPage\n }\n\n media(id_in: $id_in) {\n id\n ...WatchCard\n ...CardMedia\n }\n }\n }\n']; +/** + * The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients. + */ +export function graphql( + source: '\n query AuthWatchedList(\n $userId: Int\n $userName: String\n $status_in: [MediaListStatus]\n $type: MediaType\n $sort: [MediaListSort]\n $perPage: Int = 10\n $page: Int = 1\n ) {\n Page(page: $page, perPage: $perPage) {\n pageInfo {\n total\n perPage\n currentPage\n lastPage\n hasNextPage\n }\n\n mediaList(\n userId: $userId\n userName: $userName\n status_in: $status_in\n type: $type\n sort: $sort\n ) {\n progress\n media {\n id\n ...WatchCard\n ...CardMedia\n }\n }\n }\n }\n' +): (typeof documents)['\n query AuthWatchedList(\n $userId: Int\n $userName: String\n $status_in: [MediaListStatus]\n $type: MediaType\n $sort: [MediaListSort]\n $perPage: Int = 10\n $page: Int = 1\n ) {\n Page(page: $page, perPage: $perPage) {\n pageInfo {\n total\n perPage\n currentPage\n lastPage\n hasNextPage\n }\n\n mediaList(\n userId: $userId\n userName: $userName\n status_in: $status_in\n type: $type\n sort: $sort\n ) {\n progress\n media {\n id\n ...WatchCard\n ...CardMedia\n }\n }\n }\n }\n']; /** * The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients. */ @@ -129,18 +141,6 @@ export function graphql( export function graphql( source: '\n fragment WatchCard on Media {\n id\n title {\n userPreferred\n }\n coverImage {\n large\n }\n bannerImage\n ...MediaUnitStatsMedia\n }\n' ): (typeof documents)['\n fragment WatchCard on Media {\n id\n title {\n userPreferred\n }\n coverImage {\n large\n }\n bannerImage\n ...MediaUnitStatsMedia\n }\n']; -/** - * The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients. - */ -export function graphql( - source: '\n query WatchedList($id_in: [Int]) {\n Page(page: 1, perPage: 10) {\n media(id_in: $id_in) {\n id\n ...WatchCard\n }\n }\n }\n' -): (typeof documents)['\n query WatchedList($id_in: [Int]) {\n Page(page: 1, perPage: 10) {\n media(id_in: $id_in) {\n id\n ...WatchCard\n }\n }\n }\n']; -/** - * The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients. - */ -export function graphql( - source: '\n query AuthWatchedList(\n $userId: Int\n $userName: String\n $status_in: [MediaListStatus]\n $type: MediaType\n $sort: [MediaListSort]\n ) {\n Page(page: 1, perPage: 10) {\n mediaList(\n userId: $userId\n userName: $userName\n status_in: $status_in\n type: $type\n sort: $sort\n ) {\n progress\n media {\n id\n ...WatchCard\n }\n }\n }\n }\n' -): (typeof documents)['\n query AuthWatchedList(\n $userId: Int\n $userName: String\n $status_in: [MediaListStatus]\n $type: MediaType\n $sort: [MediaListSort]\n ) {\n Page(page: 1, perPage: 10) {\n mediaList(\n userId: $userId\n userName: $userName\n status_in: $status_in\n type: $type\n sort: $sort\n ) {\n progress\n media {\n id\n ...WatchCard\n }\n }\n }\n }\n']; /** * The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients. */ diff --git a/src/gql/graphql.ts b/src/gql/graphql.ts index af19c40..ed7bbf0 100644 --- a/src/gql/graphql.ts +++ b/src/gql/graphql.ts @@ -4562,6 +4562,80 @@ export type YearStats = { year?: Maybe; }; +export type WatchedListQueryVariables = Exact<{ + id_in?: InputMaybe< + | Array> + | InputMaybe + >; + perPage?: InputMaybe; + page?: InputMaybe; +}>; + +export type WatchedListQuery = { + __typename?: 'Query'; + Page?: { + __typename?: 'Page'; + pageInfo?: { + __typename?: 'PageInfo'; + total?: number | null; + perPage?: number | null; + currentPage?: number | null; + lastPage?: number | null; + hasNextPage?: boolean | null; + } | null; + media?: Array< + | ({ __typename?: 'Media'; id: number } & { + ' $fragmentRefs'?: { + WatchCardFragment: WatchCardFragment; + CardMediaFragment: CardMediaFragment; + }; + }) + | null + > | null; + } | null; +}; + +export type AuthWatchedListQueryVariables = Exact<{ + userId?: InputMaybe; + userName?: InputMaybe; + status_in?: InputMaybe< + Array> | InputMaybe + >; + type?: InputMaybe; + sort?: InputMaybe< + Array> | InputMaybe + >; + perPage?: InputMaybe; + page?: InputMaybe; +}>; + +export type AuthWatchedListQuery = { + __typename?: 'Query'; + Page?: { + __typename?: 'Page'; + pageInfo?: { + __typename?: 'PageInfo'; + total?: number | null; + perPage?: number | null; + currentPage?: number | null; + lastPage?: number | null; + hasNextPage?: boolean | null; + } | null; + mediaList?: Array<{ + __typename?: 'MediaList'; + progress?: number | null; + media?: + | ({ __typename?: 'Media'; id: number } & { + ' $fragmentRefs'?: { + WatchCardFragment: WatchCardFragment; + CardMediaFragment: CardMediaFragment; + }; + }) + | null; + } | null> | null; + } | null; +}; + export type ViewerQueryVariables = Exact<{ [key: string]: never }>; export type ViewerQuery = { @@ -4677,54 +4751,6 @@ export type WatchCardFragment = ({ }; }) & { ' $fragmentName'?: 'WatchCardFragment' }; -export type WatchedListQueryVariables = Exact<{ - id_in?: InputMaybe< - | Array> - | InputMaybe - >; -}>; - -export type WatchedListQuery = { - __typename?: 'Query'; - Page?: { - __typename?: 'Page'; - media?: Array< - | ({ __typename?: 'Media'; id: number } & { - ' $fragmentRefs'?: { WatchCardFragment: WatchCardFragment }; - }) - | null - > | null; - } | null; -}; - -export type AuthWatchedListQueryVariables = Exact<{ - userId?: InputMaybe; - userName?: InputMaybe; - status_in?: InputMaybe< - Array> | InputMaybe - >; - type?: InputMaybe; - sort?: InputMaybe< - Array> | InputMaybe - >; -}>; - -export type AuthWatchedListQuery = { - __typename?: 'Query'; - Page?: { - __typename?: 'Page'; - mediaList?: Array<{ - __typename?: 'MediaList'; - progress?: number | null; - media?: - | ({ __typename?: 'Media'; id: number } & { - ' $fragmentRefs'?: { WatchCardFragment: WatchCardFragment }; - }) - | null; - } | null> | null; - } | null; -}; - export type DetailsHeaderMediaFragment = { __typename?: 'Media'; bannerImage?: string | null; @@ -7202,122 +7228,262 @@ export const BannerCardMediaFragmentDoc = { }, ], } as unknown as DocumentNode; -export const ViewerDocument = { +export const WatchedListDocument = { kind: 'Document', definitions: [ { kind: 'OperationDefinition', operation: 'query', - name: { kind: 'Name', value: 'Viewer' }, + name: { kind: 'Name', value: 'WatchedList' }, + variableDefinitions: [ + { + kind: 'VariableDefinition', + variable: { + kind: 'Variable', + name: { kind: 'Name', value: 'id_in' }, + }, + type: { + kind: 'ListType', + type: { kind: 'NamedType', name: { kind: 'Name', value: 'Int' } }, + }, + }, + { + kind: 'VariableDefinition', + variable: { + kind: 'Variable', + name: { kind: 'Name', value: 'perPage' }, + }, + type: { kind: 'NamedType', name: { kind: 'Name', value: 'Int' } }, + defaultValue: { kind: 'IntValue', value: '10' }, + }, + { + kind: 'VariableDefinition', + variable: { kind: 'Variable', name: { kind: 'Name', value: 'page' } }, + type: { kind: 'NamedType', name: { kind: 'Name', value: 'Int' } }, + defaultValue: { kind: 'IntValue', value: '1' }, + }, + ], selectionSet: { kind: 'SelectionSet', selections: [ { kind: 'Field', - name: { kind: 'Name', value: 'Viewer' }, + name: { kind: 'Name', value: 'Page' }, + arguments: [ + { + kind: 'Argument', + name: { kind: 'Name', value: 'page' }, + value: { + kind: 'Variable', + name: { kind: 'Name', value: 'page' }, + }, + }, + { + kind: 'Argument', + name: { kind: 'Name', value: 'perPage' }, + value: { + kind: 'Variable', + name: { kind: 'Name', value: 'perPage' }, + }, + }, + ], selectionSet: { kind: 'SelectionSet', selections: [ - { kind: 'Field', name: { kind: 'Name', value: 'name' } }, { kind: 'Field', - name: { kind: 'Name', value: 'avatar' }, + name: { kind: 'Name', value: 'pageInfo' }, selectionSet: { kind: 'SelectionSet', selections: [ + { kind: 'Field', name: { kind: 'Name', value: 'total' } }, { kind: 'Field', - name: { kind: 'Name', value: 'medium' }, + name: { kind: 'Name', value: 'perPage' }, + }, + { + kind: 'Field', + name: { kind: 'Name', value: 'currentPage' }, + }, + { + kind: 'Field', + name: { kind: 'Name', value: 'lastPage' }, + }, + { + kind: 'Field', + name: { kind: 'Name', value: 'hasNextPage' }, + }, + ], + }, + }, + { + kind: 'Field', + name: { kind: 'Name', value: 'media' }, + arguments: [ + { + kind: 'Argument', + name: { kind: 'Name', value: 'id_in' }, + value: { + kind: 'Variable', + name: { kind: 'Name', value: 'id_in' }, + }, + }, + ], + selectionSet: { + kind: 'SelectionSet', + selections: [ + { kind: 'Field', name: { kind: 'Name', value: 'id' } }, + { + kind: 'FragmentSpread', + name: { kind: 'Name', value: 'WatchCard' }, + }, + { + kind: 'FragmentSpread', + name: { kind: 'Name', value: 'CardMedia' }, }, ], }, }, - { kind: 'Field', name: { kind: 'Name', value: 'id' } }, ], }, }, ], }, }, - ], -} as unknown as DocumentNode; -export const SaveMediaListEntryDocument = { - kind: 'Document', - definitions: [ { - kind: 'OperationDefinition', - operation: 'mutation', - name: { kind: 'Name', value: 'SaveMediaListEntry' }, - variableDefinitions: [ - { - kind: 'VariableDefinition', - variable: { kind: 'Variable', name: { kind: 'Name', value: 'id' } }, - type: { kind: 'NamedType', name: { kind: 'Name', value: 'Int' } }, - }, - { - kind: 'VariableDefinition', - variable: { - kind: 'Variable', - name: { kind: 'Name', value: 'mediaId' }, + kind: 'FragmentDefinition', + name: { kind: 'Name', value: 'MediaUnitStatsMedia' }, + typeCondition: { + kind: 'NamedType', + name: { kind: 'Name', value: 'Media' }, + }, + selectionSet: { + kind: 'SelectionSet', + selections: [ + { kind: 'Field', name: { kind: 'Name', value: 'type' } }, + { kind: 'Field', name: { kind: 'Name', value: 'episodes' } }, + { kind: 'Field', name: { kind: 'Name', value: 'chapters' } }, + { + kind: 'Field', + name: { kind: 'Name', value: 'mediaListEntry' }, + selectionSet: { + kind: 'SelectionSet', + selections: [ + { kind: 'Field', name: { kind: 'Name', value: 'progress' } }, + ], + }, }, - type: { kind: 'NamedType', name: { kind: 'Name', value: 'Int' } }, - }, - { - kind: 'VariableDefinition', - variable: { - kind: 'Variable', - name: { kind: 'Name', value: 'status' }, + { + kind: 'Field', + name: { kind: 'Name', value: 'nextAiringEpisode' }, + selectionSet: { + kind: 'SelectionSet', + selections: [ + { kind: 'Field', name: { kind: 'Name', value: 'episode' } }, + ], + }, }, - type: { - kind: 'NamedType', - name: { kind: 'Name', value: 'MediaListStatus' }, + ], + }, + }, + { + kind: 'FragmentDefinition', + name: { kind: 'Name', value: 'WatchCard' }, + typeCondition: { + kind: 'NamedType', + name: { kind: 'Name', value: 'Media' }, + }, + selectionSet: { + kind: 'SelectionSet', + selections: [ + { kind: 'Field', name: { kind: 'Name', value: 'id' } }, + { + kind: 'Field', + name: { kind: 'Name', value: 'title' }, + selectionSet: { + kind: 'SelectionSet', + selections: [ + { + kind: 'Field', + name: { kind: 'Name', value: 'userPreferred' }, + }, + ], + }, }, - }, - { - kind: 'VariableDefinition', - variable: { - kind: 'Variable', - name: { kind: 'Name', value: 'score' }, + { + kind: 'Field', + name: { kind: 'Name', value: 'coverImage' }, + selectionSet: { + kind: 'SelectionSet', + selections: [ + { kind: 'Field', name: { kind: 'Name', value: 'large' } }, + ], + }, }, - type: { kind: 'NamedType', name: { kind: 'Name', value: 'Float' } }, - }, - { - kind: 'VariableDefinition', - variable: { - kind: 'Variable', - name: { kind: 'Name', value: 'scoreRaw' }, + { kind: 'Field', name: { kind: 'Name', value: 'bannerImage' } }, + { + kind: 'FragmentSpread', + name: { kind: 'Name', value: 'MediaUnitStatsMedia' }, }, - type: { kind: 'NamedType', name: { kind: 'Name', value: 'Int' } }, - }, - { - kind: 'VariableDefinition', - variable: { - kind: 'Variable', - name: { kind: 'Name', value: 'progress' }, + ], + }, + }, + { + kind: 'FragmentDefinition', + name: { kind: 'Name', value: 'CardMedia' }, + typeCondition: { + kind: 'NamedType', + name: { kind: 'Name', value: 'Media' }, + }, + selectionSet: { + kind: 'SelectionSet', + selections: [ + { kind: 'Field', name: { kind: 'Name', value: 'id' } }, + { + kind: 'Field', + name: { kind: 'Name', value: 'title' }, + selectionSet: { + kind: 'SelectionSet', + selections: [ + { + kind: 'Field', + name: { kind: 'Name', value: 'userPreferred' }, + }, + ], + }, }, - type: { kind: 'NamedType', name: { kind: 'Name', value: 'Int' } }, - }, - { - kind: 'VariableDefinition', - variable: { - kind: 'Variable', - name: { kind: 'Name', value: 'progressVolumes' }, + { + kind: 'Field', + name: { kind: 'Name', value: 'coverImage' }, + selectionSet: { + kind: 'SelectionSet', + selections: [ + { kind: 'Field', name: { kind: 'Name', value: 'large' } }, + ], + }, }, - type: { kind: 'NamedType', name: { kind: 'Name', value: 'Int' } }, - }, - { - kind: 'VariableDefinition', - variable: { - kind: 'Variable', - name: { kind: 'Name', value: 'repeat' }, + { + kind: 'FragmentSpread', + name: { kind: 'Name', value: 'MediaUnitStatsMedia' }, }, - type: { kind: 'NamedType', name: { kind: 'Name', value: 'Int' } }, - }, + ], + }, + }, + ], +} as unknown as DocumentNode; +export const AuthWatchedListDocument = { + kind: 'Document', + definitions: [ + { + kind: 'OperationDefinition', + operation: 'query', + name: { kind: 'Name', value: 'AuthWatchedList' }, + variableDefinitions: [ { kind: 'VariableDefinition', variable: { kind: 'Variable', - name: { kind: 'Name', value: 'priority' }, + name: { kind: 'Name', value: 'userId' }, }, type: { kind: 'NamedType', name: { kind: 'Name', value: 'Int' } }, }, @@ -7325,15 +7491,7 @@ export const SaveMediaListEntryDocument = { kind: 'VariableDefinition', variable: { kind: 'Variable', - name: { kind: 'Name', value: 'private' }, - }, - type: { kind: 'NamedType', name: { kind: 'Name', value: 'Boolean' } }, - }, - { - kind: 'VariableDefinition', - variable: { - kind: 'Variable', - name: { kind: 'Name', value: 'notes' }, + name: { kind: 'Name', value: 'userName' }, }, type: { kind: 'NamedType', name: { kind: 'Name', value: 'String' } }, }, @@ -7341,56 +7499,49 @@ export const SaveMediaListEntryDocument = { kind: 'VariableDefinition', variable: { kind: 'Variable', - name: { kind: 'Name', value: 'hiddenFromStatusLists' }, - }, - type: { kind: 'NamedType', name: { kind: 'Name', value: 'Boolean' } }, - }, - { - kind: 'VariableDefinition', - variable: { - kind: 'Variable', - name: { kind: 'Name', value: 'customLists' }, + name: { kind: 'Name', value: 'status_in' }, }, type: { kind: 'ListType', type: { kind: 'NamedType', - name: { kind: 'Name', value: 'String' }, + name: { kind: 'Name', value: 'MediaListStatus' }, }, }, }, { kind: 'VariableDefinition', - variable: { - kind: 'Variable', - name: { kind: 'Name', value: 'advancedScores' }, - }, + variable: { kind: 'Variable', name: { kind: 'Name', value: 'type' } }, type: { - kind: 'ListType', - type: { kind: 'NamedType', name: { kind: 'Name', value: 'Float' } }, + kind: 'NamedType', + name: { kind: 'Name', value: 'MediaType' }, }, }, { kind: 'VariableDefinition', - variable: { - kind: 'Variable', - name: { kind: 'Name', value: 'startedAt' }, - }, + variable: { kind: 'Variable', name: { kind: 'Name', value: 'sort' } }, type: { - kind: 'NamedType', - name: { kind: 'Name', value: 'FuzzyDateInput' }, + kind: 'ListType', + type: { + kind: 'NamedType', + name: { kind: 'Name', value: 'MediaListSort' }, + }, }, }, { kind: 'VariableDefinition', variable: { kind: 'Variable', - name: { kind: 'Name', value: 'completedAt' }, - }, - type: { - kind: 'NamedType', - name: { kind: 'Name', value: 'FuzzyDateInput' }, + name: { kind: 'Name', value: 'perPage' }, }, + type: { kind: 'NamedType', name: { kind: 'Name', value: 'Int' } }, + defaultValue: { kind: 'IntValue', value: '10' }, + }, + { + kind: 'VariableDefinition', + variable: { kind: 'Variable', name: { kind: 'Name', value: 'page' } }, + type: { kind: 'NamedType', name: { kind: 'Name', value: 'Int' } }, + defaultValue: { kind: 'IntValue', value: '1' }, }, ], selectionSet: { @@ -7398,248 +7549,120 @@ export const SaveMediaListEntryDocument = { selections: [ { kind: 'Field', - name: { kind: 'Name', value: 'SaveMediaListEntry' }, + name: { kind: 'Name', value: 'Page' }, arguments: [ { kind: 'Argument', - name: { kind: 'Name', value: 'id' }, - value: { - kind: 'Variable', - name: { kind: 'Name', value: 'id' }, - }, - }, - { - kind: 'Argument', - name: { kind: 'Name', value: 'mediaId' }, + name: { kind: 'Name', value: 'page' }, value: { kind: 'Variable', - name: { kind: 'Name', value: 'mediaId' }, + name: { kind: 'Name', value: 'page' }, }, }, { kind: 'Argument', - name: { kind: 'Name', value: 'status' }, + name: { kind: 'Name', value: 'perPage' }, value: { kind: 'Variable', - name: { kind: 'Name', value: 'status' }, + name: { kind: 'Name', value: 'perPage' }, }, }, - { - kind: 'Argument', - name: { kind: 'Name', value: 'score' }, - value: { - kind: 'Variable', - name: { kind: 'Name', value: 'score' }, + ], + selectionSet: { + kind: 'SelectionSet', + selections: [ + { + kind: 'Field', + name: { kind: 'Name', value: 'pageInfo' }, + selectionSet: { + kind: 'SelectionSet', + selections: [ + { kind: 'Field', name: { kind: 'Name', value: 'total' } }, + { + kind: 'Field', + name: { kind: 'Name', value: 'perPage' }, + }, + { + kind: 'Field', + name: { kind: 'Name', value: 'currentPage' }, + }, + { + kind: 'Field', + name: { kind: 'Name', value: 'lastPage' }, + }, + { + kind: 'Field', + name: { kind: 'Name', value: 'hasNextPage' }, + }, + ], + }, }, - }, - { - kind: 'Argument', - name: { kind: 'Name', value: 'scoreRaw' }, - value: { - kind: 'Variable', - name: { kind: 'Name', value: 'scoreRaw' }, - }, - }, - { - kind: 'Argument', - name: { kind: 'Name', value: 'progress' }, - value: { - kind: 'Variable', - name: { kind: 'Name', value: 'progress' }, - }, - }, - { - kind: 'Argument', - name: { kind: 'Name', value: 'progressVolumes' }, - value: { - kind: 'Variable', - name: { kind: 'Name', value: 'progressVolumes' }, - }, - }, - { - kind: 'Argument', - name: { kind: 'Name', value: 'repeat' }, - value: { - kind: 'Variable', - name: { kind: 'Name', value: 'repeat' }, - }, - }, - { - kind: 'Argument', - name: { kind: 'Name', value: 'priority' }, - value: { - kind: 'Variable', - name: { kind: 'Name', value: 'priority' }, - }, - }, - { - kind: 'Argument', - name: { kind: 'Name', value: 'private' }, - value: { - kind: 'Variable', - name: { kind: 'Name', value: 'private' }, - }, - }, - { - kind: 'Argument', - name: { kind: 'Name', value: 'notes' }, - value: { - kind: 'Variable', - name: { kind: 'Name', value: 'notes' }, - }, - }, - { - kind: 'Argument', - name: { kind: 'Name', value: 'hiddenFromStatusLists' }, - value: { - kind: 'Variable', - name: { kind: 'Name', value: 'hiddenFromStatusLists' }, - }, - }, - { - kind: 'Argument', - name: { kind: 'Name', value: 'customLists' }, - value: { - kind: 'Variable', - name: { kind: 'Name', value: 'customLists' }, - }, - }, - { - kind: 'Argument', - name: { kind: 'Name', value: 'advancedScores' }, - value: { - kind: 'Variable', - name: { kind: 'Name', value: 'advancedScores' }, - }, - }, - { - kind: 'Argument', - name: { kind: 'Name', value: 'startedAt' }, - value: { - kind: 'Variable', - name: { kind: 'Name', value: 'startedAt' }, - }, - }, - { - kind: 'Argument', - name: { kind: 'Name', value: 'completedAt' }, - value: { - kind: 'Variable', - name: { kind: 'Name', value: 'completedAt' }, - }, - }, - ], - selectionSet: { - kind: 'SelectionSet', - selections: [ - { kind: 'Field', name: { kind: 'Name', value: 'progress' } }, { kind: 'Field', - name: { kind: 'Name', value: 'score' }, + name: { kind: 'Name', value: 'mediaList' }, arguments: [ { kind: 'Argument', - name: { kind: 'Name', value: 'format' }, - value: { kind: 'EnumValue', value: 'POINT_10_DECIMAL' }, + name: { kind: 'Name', value: 'userId' }, + value: { + kind: 'Variable', + name: { kind: 'Name', value: 'userId' }, + }, }, - ], - }, - { kind: 'Field', name: { kind: 'Name', value: 'status' } }, - ], - }, - }, - ], - }, - }, - ], -} as unknown as DocumentNode< - SaveMediaListEntryMutation, - SaveMediaListEntryMutationVariables ->; -export const AiringScheduleDocument = { - kind: 'Document', - definitions: [ - { - kind: 'OperationDefinition', - operation: 'query', - name: { kind: 'Name', value: 'AiringSchedule' }, - variableDefinitions: [ - { - kind: 'VariableDefinition', - variable: { - kind: 'Variable', - name: { kind: 'Name', value: 'airingAt_greater' }, - }, - type: { kind: 'NamedType', name: { kind: 'Name', value: 'Int' } }, - }, - { - kind: 'VariableDefinition', - variable: { - kind: 'Variable', - name: { kind: 'Name', value: 'airingAt_lesser' }, - }, - type: { kind: 'NamedType', name: { kind: 'Name', value: 'Int' } }, - }, - ], - selectionSet: { - kind: 'SelectionSet', - selections: [ - { - kind: 'Field', - name: { kind: 'Name', value: 'Page' }, - arguments: [ - { - kind: 'Argument', - name: { kind: 'Name', value: 'page' }, - value: { kind: 'IntValue', value: '1' }, - }, - { - kind: 'Argument', - name: { kind: 'Name', value: 'perPage' }, - value: { kind: 'IntValue', value: '20' }, - }, - ], - selectionSet: { - kind: 'SelectionSet', - selections: [ - { - kind: 'Field', - name: { kind: 'Name', value: 'airingSchedules' }, - arguments: [ { kind: 'Argument', - name: { kind: 'Name', value: 'airingAt_greater' }, + name: { kind: 'Name', value: 'userName' }, value: { kind: 'Variable', - name: { kind: 'Name', value: 'airingAt_greater' }, + name: { kind: 'Name', value: 'userName' }, }, }, { kind: 'Argument', - name: { kind: 'Name', value: 'airingAt_lesser' }, + name: { kind: 'Name', value: 'status_in' }, value: { kind: 'Variable', - name: { kind: 'Name', value: 'airingAt_lesser' }, + name: { kind: 'Name', value: 'status_in' }, + }, + }, + { + kind: 'Argument', + name: { kind: 'Name', value: 'type' }, + value: { + kind: 'Variable', + name: { kind: 'Name', value: 'type' }, }, }, { kind: 'Argument', name: { kind: 'Name', value: 'sort' }, value: { - kind: 'ListValue', - values: [{ kind: 'EnumValue', value: 'TIME_DESC' }], + kind: 'Variable', + name: { kind: 'Name', value: 'sort' }, }, }, ], selectionSet: { kind: 'SelectionSet', selections: [ + { + kind: 'Field', + name: { kind: 'Name', value: 'progress' }, + }, { kind: 'Field', name: { kind: 'Name', value: 'media' }, selectionSet: { kind: 'SelectionSet', selections: [ + { + kind: 'Field', + name: { kind: 'Name', value: 'id' }, + }, + { + kind: 'FragmentSpread', + name: { kind: 'Name', value: 'WatchCard' }, + }, { kind: 'FragmentSpread', name: { kind: 'Name', value: 'CardMedia' }, @@ -7694,7 +7717,7 @@ export const AiringScheduleDocument = { }, { kind: 'FragmentDefinition', - name: { kind: 'Name', value: 'CardMedia' }, + name: { kind: 'Name', value: 'WatchCard' }, typeCondition: { kind: 'NamedType', name: { kind: 'Name', value: 'Media' }, @@ -7726,6 +7749,7 @@ export const AiringScheduleDocument = { ], }, }, + { kind: 'Field', name: { kind: 'Name', value: 'bannerImage' } }, { kind: 'FragmentSpread', name: { kind: 'Name', value: 'MediaUnitStatsMedia' }, @@ -7733,215 +7757,427 @@ export const AiringScheduleDocument = { ], }, }, - ], -} as unknown as DocumentNode; -export const PopularThisSeasonDocument = { - kind: 'Document', - definitions: [ { - kind: 'OperationDefinition', - operation: 'query', - name: { kind: 'Name', value: 'PopularThisSeason' }, - variableDefinitions: [ - { - kind: 'VariableDefinition', - variable: { - kind: 'Variable', - name: { kind: 'Name', value: 'season' }, - }, - type: { - kind: 'NamedType', - name: { kind: 'Name', value: 'MediaSeason' }, - }, - }, - { - kind: 'VariableDefinition', - variable: { - kind: 'Variable', - name: { kind: 'Name', value: 'seasonYear' }, - }, - type: { kind: 'NamedType', name: { kind: 'Name', value: 'Int' } }, - }, - ], + kind: 'FragmentDefinition', + name: { kind: 'Name', value: 'CardMedia' }, + typeCondition: { + kind: 'NamedType', + name: { kind: 'Name', value: 'Media' }, + }, selectionSet: { kind: 'SelectionSet', selections: [ + { kind: 'Field', name: { kind: 'Name', value: 'id' } }, { kind: 'Field', - name: { kind: 'Name', value: 'Page' }, - arguments: [ - { - kind: 'Argument', - name: { kind: 'Name', value: 'page' }, - value: { kind: 'IntValue', value: '1' }, - }, - { - kind: 'Argument', - name: { kind: 'Name', value: 'perPage' }, - value: { kind: 'IntValue', value: '10' }, - }, - ], + name: { kind: 'Name', value: 'title' }, selectionSet: { kind: 'SelectionSet', selections: [ { kind: 'Field', - name: { kind: 'Name', value: 'media' }, - arguments: [ - { - kind: 'Argument', - name: { kind: 'Name', value: 'type' }, - value: { kind: 'EnumValue', value: 'ANIME' }, - }, - { - kind: 'Argument', - name: { kind: 'Name', value: 'sort' }, - value: { - kind: 'ListValue', - values: [ - { kind: 'EnumValue', value: 'POPULARITY_DESC' }, - ], - }, - }, - { - kind: 'Argument', - name: { kind: 'Name', value: 'season' }, - value: { - kind: 'Variable', - name: { kind: 'Name', value: 'season' }, - }, - }, - { - kind: 'Argument', - name: { kind: 'Name', value: 'seasonYear' }, - value: { - kind: 'Variable', - name: { kind: 'Name', value: 'seasonYear' }, - }, - }, - ], - selectionSet: { - kind: 'SelectionSet', - selections: [ - { - kind: 'FragmentSpread', - name: { kind: 'Name', value: 'CardMedia' }, - }, - ], - }, + name: { kind: 'Name', value: 'userPreferred' }, }, ], }, }, - ], - }, - }, - { - kind: 'FragmentDefinition', - name: { kind: 'Name', value: 'MediaUnitStatsMedia' }, - typeCondition: { - kind: 'NamedType', - name: { kind: 'Name', value: 'Media' }, - }, - selectionSet: { - kind: 'SelectionSet', - selections: [ - { kind: 'Field', name: { kind: 'Name', value: 'type' } }, - { kind: 'Field', name: { kind: 'Name', value: 'episodes' } }, - { kind: 'Field', name: { kind: 'Name', value: 'chapters' } }, { kind: 'Field', - name: { kind: 'Name', value: 'mediaListEntry' }, + name: { kind: 'Name', value: 'coverImage' }, selectionSet: { kind: 'SelectionSet', selections: [ - { kind: 'Field', name: { kind: 'Name', value: 'progress' } }, + { kind: 'Field', name: { kind: 'Name', value: 'large' } }, ], }, }, + { + kind: 'FragmentSpread', + name: { kind: 'Name', value: 'MediaUnitStatsMedia' }, + }, + ], + }, + }, + ], +} as unknown as DocumentNode< + AuthWatchedListQuery, + AuthWatchedListQueryVariables +>; +export const ViewerDocument = { + kind: 'Document', + definitions: [ + { + kind: 'OperationDefinition', + operation: 'query', + name: { kind: 'Name', value: 'Viewer' }, + selectionSet: { + kind: 'SelectionSet', + selections: [ { kind: 'Field', - name: { kind: 'Name', value: 'nextAiringEpisode' }, + name: { kind: 'Name', value: 'Viewer' }, selectionSet: { kind: 'SelectionSet', selections: [ - { kind: 'Field', name: { kind: 'Name', value: 'episode' } }, + { kind: 'Field', name: { kind: 'Name', value: 'name' } }, + { + kind: 'Field', + name: { kind: 'Name', value: 'avatar' }, + selectionSet: { + kind: 'SelectionSet', + selections: [ + { + kind: 'Field', + name: { kind: 'Name', value: 'medium' }, + }, + ], + }, + }, + { kind: 'Field', name: { kind: 'Name', value: 'id' } }, ], }, }, ], }, }, + ], +} as unknown as DocumentNode; +export const SaveMediaListEntryDocument = { + kind: 'Document', + definitions: [ { - kind: 'FragmentDefinition', - name: { kind: 'Name', value: 'CardMedia' }, - typeCondition: { - kind: 'NamedType', - name: { kind: 'Name', value: 'Media' }, - }, + kind: 'OperationDefinition', + operation: 'mutation', + name: { kind: 'Name', value: 'SaveMediaListEntry' }, + variableDefinitions: [ + { + kind: 'VariableDefinition', + variable: { kind: 'Variable', name: { kind: 'Name', value: 'id' } }, + type: { kind: 'NamedType', name: { kind: 'Name', value: 'Int' } }, + }, + { + kind: 'VariableDefinition', + variable: { + kind: 'Variable', + name: { kind: 'Name', value: 'mediaId' }, + }, + type: { kind: 'NamedType', name: { kind: 'Name', value: 'Int' } }, + }, + { + kind: 'VariableDefinition', + variable: { + kind: 'Variable', + name: { kind: 'Name', value: 'status' }, + }, + type: { + kind: 'NamedType', + name: { kind: 'Name', value: 'MediaListStatus' }, + }, + }, + { + kind: 'VariableDefinition', + variable: { + kind: 'Variable', + name: { kind: 'Name', value: 'score' }, + }, + type: { kind: 'NamedType', name: { kind: 'Name', value: 'Float' } }, + }, + { + kind: 'VariableDefinition', + variable: { + kind: 'Variable', + name: { kind: 'Name', value: 'scoreRaw' }, + }, + type: { kind: 'NamedType', name: { kind: 'Name', value: 'Int' } }, + }, + { + kind: 'VariableDefinition', + variable: { + kind: 'Variable', + name: { kind: 'Name', value: 'progress' }, + }, + type: { kind: 'NamedType', name: { kind: 'Name', value: 'Int' } }, + }, + { + kind: 'VariableDefinition', + variable: { + kind: 'Variable', + name: { kind: 'Name', value: 'progressVolumes' }, + }, + type: { kind: 'NamedType', name: { kind: 'Name', value: 'Int' } }, + }, + { + kind: 'VariableDefinition', + variable: { + kind: 'Variable', + name: { kind: 'Name', value: 'repeat' }, + }, + type: { kind: 'NamedType', name: { kind: 'Name', value: 'Int' } }, + }, + { + kind: 'VariableDefinition', + variable: { + kind: 'Variable', + name: { kind: 'Name', value: 'priority' }, + }, + type: { kind: 'NamedType', name: { kind: 'Name', value: 'Int' } }, + }, + { + kind: 'VariableDefinition', + variable: { + kind: 'Variable', + name: { kind: 'Name', value: 'private' }, + }, + type: { kind: 'NamedType', name: { kind: 'Name', value: 'Boolean' } }, + }, + { + kind: 'VariableDefinition', + variable: { + kind: 'Variable', + name: { kind: 'Name', value: 'notes' }, + }, + type: { kind: 'NamedType', name: { kind: 'Name', value: 'String' } }, + }, + { + kind: 'VariableDefinition', + variable: { + kind: 'Variable', + name: { kind: 'Name', value: 'hiddenFromStatusLists' }, + }, + type: { kind: 'NamedType', name: { kind: 'Name', value: 'Boolean' } }, + }, + { + kind: 'VariableDefinition', + variable: { + kind: 'Variable', + name: { kind: 'Name', value: 'customLists' }, + }, + type: { + kind: 'ListType', + type: { + kind: 'NamedType', + name: { kind: 'Name', value: 'String' }, + }, + }, + }, + { + kind: 'VariableDefinition', + variable: { + kind: 'Variable', + name: { kind: 'Name', value: 'advancedScores' }, + }, + type: { + kind: 'ListType', + type: { kind: 'NamedType', name: { kind: 'Name', value: 'Float' } }, + }, + }, + { + kind: 'VariableDefinition', + variable: { + kind: 'Variable', + name: { kind: 'Name', value: 'startedAt' }, + }, + type: { + kind: 'NamedType', + name: { kind: 'Name', value: 'FuzzyDateInput' }, + }, + }, + { + kind: 'VariableDefinition', + variable: { + kind: 'Variable', + name: { kind: 'Name', value: 'completedAt' }, + }, + type: { + kind: 'NamedType', + name: { kind: 'Name', value: 'FuzzyDateInput' }, + }, + }, + ], selectionSet: { kind: 'SelectionSet', selections: [ - { kind: 'Field', name: { kind: 'Name', value: 'id' } }, { kind: 'Field', - name: { kind: 'Name', value: 'title' }, + name: { kind: 'Name', value: 'SaveMediaListEntry' }, + arguments: [ + { + kind: 'Argument', + name: { kind: 'Name', value: 'id' }, + value: { + kind: 'Variable', + name: { kind: 'Name', value: 'id' }, + }, + }, + { + kind: 'Argument', + name: { kind: 'Name', value: 'mediaId' }, + value: { + kind: 'Variable', + name: { kind: 'Name', value: 'mediaId' }, + }, + }, + { + kind: 'Argument', + name: { kind: 'Name', value: 'status' }, + value: { + kind: 'Variable', + name: { kind: 'Name', value: 'status' }, + }, + }, + { + kind: 'Argument', + name: { kind: 'Name', value: 'score' }, + value: { + kind: 'Variable', + name: { kind: 'Name', value: 'score' }, + }, + }, + { + kind: 'Argument', + name: { kind: 'Name', value: 'scoreRaw' }, + value: { + kind: 'Variable', + name: { kind: 'Name', value: 'scoreRaw' }, + }, + }, + { + kind: 'Argument', + name: { kind: 'Name', value: 'progress' }, + value: { + kind: 'Variable', + name: { kind: 'Name', value: 'progress' }, + }, + }, + { + kind: 'Argument', + name: { kind: 'Name', value: 'progressVolumes' }, + value: { + kind: 'Variable', + name: { kind: 'Name', value: 'progressVolumes' }, + }, + }, + { + kind: 'Argument', + name: { kind: 'Name', value: 'repeat' }, + value: { + kind: 'Variable', + name: { kind: 'Name', value: 'repeat' }, + }, + }, + { + kind: 'Argument', + name: { kind: 'Name', value: 'priority' }, + value: { + kind: 'Variable', + name: { kind: 'Name', value: 'priority' }, + }, + }, + { + kind: 'Argument', + name: { kind: 'Name', value: 'private' }, + value: { + kind: 'Variable', + name: { kind: 'Name', value: 'private' }, + }, + }, + { + kind: 'Argument', + name: { kind: 'Name', value: 'notes' }, + value: { + kind: 'Variable', + name: { kind: 'Name', value: 'notes' }, + }, + }, + { + kind: 'Argument', + name: { kind: 'Name', value: 'hiddenFromStatusLists' }, + value: { + kind: 'Variable', + name: { kind: 'Name', value: 'hiddenFromStatusLists' }, + }, + }, + { + kind: 'Argument', + name: { kind: 'Name', value: 'customLists' }, + value: { + kind: 'Variable', + name: { kind: 'Name', value: 'customLists' }, + }, + }, + { + kind: 'Argument', + name: { kind: 'Name', value: 'advancedScores' }, + value: { + kind: 'Variable', + name: { kind: 'Name', value: 'advancedScores' }, + }, + }, + { + kind: 'Argument', + name: { kind: 'Name', value: 'startedAt' }, + value: { + kind: 'Variable', + name: { kind: 'Name', value: 'startedAt' }, + }, + }, + { + kind: 'Argument', + name: { kind: 'Name', value: 'completedAt' }, + value: { + kind: 'Variable', + name: { kind: 'Name', value: 'completedAt' }, + }, + }, + ], selectionSet: { kind: 'SelectionSet', selections: [ + { kind: 'Field', name: { kind: 'Name', value: 'progress' } }, { kind: 'Field', - name: { kind: 'Name', value: 'userPreferred' }, + name: { kind: 'Name', value: 'score' }, + arguments: [ + { + kind: 'Argument', + name: { kind: 'Name', value: 'format' }, + value: { kind: 'EnumValue', value: 'POINT_10_DECIMAL' }, + }, + ], }, + { kind: 'Field', name: { kind: 'Name', value: 'status' } }, ], }, }, - { - kind: 'Field', - name: { kind: 'Name', value: 'coverImage' }, - selectionSet: { - kind: 'SelectionSet', - selections: [ - { kind: 'Field', name: { kind: 'Name', value: 'large' } }, - ], - }, - }, - { - kind: 'FragmentSpread', - name: { kind: 'Name', value: 'MediaUnitStatsMedia' }, - }, ], }, }, ], } as unknown as DocumentNode< - PopularThisSeasonQuery, - PopularThisSeasonQueryVariables + SaveMediaListEntryMutation, + SaveMediaListEntryMutationVariables >; -export const UpcomingNextSeasonDocument = { +export const AiringScheduleDocument = { kind: 'Document', definitions: [ { kind: 'OperationDefinition', operation: 'query', - name: { kind: 'Name', value: 'UpcomingNextSeason' }, + name: { kind: 'Name', value: 'AiringSchedule' }, variableDefinitions: [ { kind: 'VariableDefinition', variable: { kind: 'Variable', - name: { kind: 'Name', value: 'season' }, - }, - type: { - kind: 'NamedType', - name: { kind: 'Name', value: 'MediaSeason' }, + name: { kind: 'Name', value: 'airingAt_greater' }, }, + type: { kind: 'NamedType', name: { kind: 'Name', value: 'Int' } }, }, { kind: 'VariableDefinition', variable: { kind: 'Variable', - name: { kind: 'Name', value: 'seasonYear' }, + name: { kind: 'Name', value: 'airingAt_lesser' }, }, type: { kind: 'NamedType', name: { kind: 'Name', value: 'Int' } }, }, @@ -7961,7 +8197,7 @@ export const UpcomingNextSeasonDocument = { { kind: 'Argument', name: { kind: 'Name', value: 'perPage' }, - value: { kind: 'IntValue', value: '10' }, + value: { kind: 'IntValue', value: '20' }, }, ], selectionSet: { @@ -7969,37 +8205,30 @@ export const UpcomingNextSeasonDocument = { selections: [ { kind: 'Field', - name: { kind: 'Name', value: 'media' }, + name: { kind: 'Name', value: 'airingSchedules' }, arguments: [ { kind: 'Argument', - name: { kind: 'Name', value: 'type' }, - value: { kind: 'EnumValue', value: 'ANIME' }, - }, - { - kind: 'Argument', - name: { kind: 'Name', value: 'sort' }, + name: { kind: 'Name', value: 'airingAt_greater' }, value: { - kind: 'ListValue', - values: [ - { kind: 'EnumValue', value: 'POPULARITY_DESC' }, - ], + kind: 'Variable', + name: { kind: 'Name', value: 'airingAt_greater' }, }, }, { kind: 'Argument', - name: { kind: 'Name', value: 'season' }, + name: { kind: 'Name', value: 'airingAt_lesser' }, value: { kind: 'Variable', - name: { kind: 'Name', value: 'season' }, + name: { kind: 'Name', value: 'airingAt_lesser' }, }, }, { kind: 'Argument', - name: { kind: 'Name', value: 'seasonYear' }, + name: { kind: 'Name', value: 'sort' }, value: { - kind: 'Variable', - name: { kind: 'Name', value: 'seasonYear' }, + kind: 'ListValue', + values: [{ kind: 'EnumValue', value: 'TIME_DESC' }], }, }, ], @@ -8007,8 +8236,17 @@ export const UpcomingNextSeasonDocument = { kind: 'SelectionSet', selections: [ { - kind: 'FragmentSpread', - name: { kind: 'Name', value: 'CardMedia' }, + kind: 'Field', + name: { kind: 'Name', value: 'media' }, + selectionSet: { + kind: 'SelectionSet', + selections: [ + { + kind: 'FragmentSpread', + name: { kind: 'Name', value: 'CardMedia' }, + }, + ], + }, }, ], }, @@ -8097,28 +8335,33 @@ export const UpcomingNextSeasonDocument = { }, }, ], -} as unknown as DocumentNode< - UpcomingNextSeasonQuery, - UpcomingNextSeasonQueryVariables ->; -export const WatchedListDocument = { +} as unknown as DocumentNode; +export const PopularThisSeasonDocument = { kind: 'Document', definitions: [ { kind: 'OperationDefinition', operation: 'query', - name: { kind: 'Name', value: 'WatchedList' }, + name: { kind: 'Name', value: 'PopularThisSeason' }, variableDefinitions: [ { kind: 'VariableDefinition', variable: { kind: 'Variable', - name: { kind: 'Name', value: 'id_in' }, + name: { kind: 'Name', value: 'season' }, }, type: { - kind: 'ListType', - type: { kind: 'NamedType', name: { kind: 'Name', value: 'Int' } }, + kind: 'NamedType', + name: { kind: 'Name', value: 'MediaSeason' }, + }, + }, + { + kind: 'VariableDefinition', + variable: { + kind: 'Variable', + name: { kind: 'Name', value: 'seasonYear' }, }, + type: { kind: 'NamedType', name: { kind: 'Name', value: 'Int' } }, }, ], selectionSet: { @@ -8148,20 +8391,42 @@ export const WatchedListDocument = { arguments: [ { kind: 'Argument', - name: { kind: 'Name', value: 'id_in' }, + name: { kind: 'Name', value: 'type' }, + value: { kind: 'EnumValue', value: 'ANIME' }, + }, + { + kind: 'Argument', + name: { kind: 'Name', value: 'sort' }, + value: { + kind: 'ListValue', + values: [ + { kind: 'EnumValue', value: 'POPULARITY_DESC' }, + ], + }, + }, + { + kind: 'Argument', + name: { kind: 'Name', value: 'season' }, value: { kind: 'Variable', - name: { kind: 'Name', value: 'id_in' }, + name: { kind: 'Name', value: 'season' }, + }, + }, + { + kind: 'Argument', + name: { kind: 'Name', value: 'seasonYear' }, + value: { + kind: 'Variable', + name: { kind: 'Name', value: 'seasonYear' }, }, }, ], selectionSet: { kind: 'SelectionSet', selections: [ - { kind: 'Field', name: { kind: 'Name', value: 'id' } }, { kind: 'FragmentSpread', - name: { kind: 'Name', value: 'WatchCard' }, + name: { kind: 'Name', value: 'CardMedia' }, }, ], }, @@ -8210,7 +8475,7 @@ export const WatchedListDocument = { }, { kind: 'FragmentDefinition', - name: { kind: 'Name', value: 'WatchCard' }, + name: { kind: 'Name', value: 'CardMedia' }, typeCondition: { kind: 'NamedType', name: { kind: 'Name', value: 'Media' }, @@ -8242,7 +8507,6 @@ export const WatchedListDocument = { ], }, }, - { kind: 'Field', name: { kind: 'Name', value: 'bannerImage' } }, { kind: 'FragmentSpread', name: { kind: 'Name', value: 'MediaUnitStatsMedia' }, @@ -8251,63 +8515,36 @@ export const WatchedListDocument = { }, }, ], -} as unknown as DocumentNode; -export const AuthWatchedListDocument = { +} as unknown as DocumentNode< + PopularThisSeasonQuery, + PopularThisSeasonQueryVariables +>; +export const UpcomingNextSeasonDocument = { kind: 'Document', definitions: [ { kind: 'OperationDefinition', operation: 'query', - name: { kind: 'Name', value: 'AuthWatchedList' }, + name: { kind: 'Name', value: 'UpcomingNextSeason' }, variableDefinitions: [ { kind: 'VariableDefinition', variable: { kind: 'Variable', - name: { kind: 'Name', value: 'userId' }, - }, - type: { kind: 'NamedType', name: { kind: 'Name', value: 'Int' } }, - }, - { - kind: 'VariableDefinition', - variable: { - kind: 'Variable', - name: { kind: 'Name', value: 'userName' }, - }, - type: { kind: 'NamedType', name: { kind: 'Name', value: 'String' } }, - }, - { - kind: 'VariableDefinition', - variable: { - kind: 'Variable', - name: { kind: 'Name', value: 'status_in' }, - }, - type: { - kind: 'ListType', - type: { - kind: 'NamedType', - name: { kind: 'Name', value: 'MediaListStatus' }, - }, + name: { kind: 'Name', value: 'season' }, }, - }, - { - kind: 'VariableDefinition', - variable: { kind: 'Variable', name: { kind: 'Name', value: 'type' } }, type: { kind: 'NamedType', - name: { kind: 'Name', value: 'MediaType' }, + name: { kind: 'Name', value: 'MediaSeason' }, }, }, { kind: 'VariableDefinition', - variable: { kind: 'Variable', name: { kind: 'Name', value: 'sort' } }, - type: { - kind: 'ListType', - type: { - kind: 'NamedType', - name: { kind: 'Name', value: 'MediaListSort' }, - }, + variable: { + kind: 'Variable', + name: { kind: 'Name', value: 'seasonYear' }, }, + type: { kind: 'NamedType', name: { kind: 'Name', value: 'Int' } }, }, ], selectionSet: { @@ -8333,46 +8570,37 @@ export const AuthWatchedListDocument = { selections: [ { kind: 'Field', - name: { kind: 'Name', value: 'mediaList' }, + name: { kind: 'Name', value: 'media' }, arguments: [ { kind: 'Argument', - name: { kind: 'Name', value: 'userId' }, - value: { - kind: 'Variable', - name: { kind: 'Name', value: 'userId' }, - }, - }, - { - kind: 'Argument', - name: { kind: 'Name', value: 'userName' }, - value: { - kind: 'Variable', - name: { kind: 'Name', value: 'userName' }, - }, + name: { kind: 'Name', value: 'type' }, + value: { kind: 'EnumValue', value: 'ANIME' }, }, { kind: 'Argument', - name: { kind: 'Name', value: 'status_in' }, + name: { kind: 'Name', value: 'sort' }, value: { - kind: 'Variable', - name: { kind: 'Name', value: 'status_in' }, + kind: 'ListValue', + values: [ + { kind: 'EnumValue', value: 'POPULARITY_DESC' }, + ], }, }, { kind: 'Argument', - name: { kind: 'Name', value: 'type' }, + name: { kind: 'Name', value: 'season' }, value: { kind: 'Variable', - name: { kind: 'Name', value: 'type' }, + name: { kind: 'Name', value: 'season' }, }, }, { kind: 'Argument', - name: { kind: 'Name', value: 'sort' }, + name: { kind: 'Name', value: 'seasonYear' }, value: { kind: 'Variable', - name: { kind: 'Name', value: 'sort' }, + name: { kind: 'Name', value: 'seasonYear' }, }, }, ], @@ -8380,25 +8608,8 @@ export const AuthWatchedListDocument = { kind: 'SelectionSet', selections: [ { - kind: 'Field', - name: { kind: 'Name', value: 'progress' }, - }, - { - kind: 'Field', - name: { kind: 'Name', value: 'media' }, - selectionSet: { - kind: 'SelectionSet', - selections: [ - { - kind: 'Field', - name: { kind: 'Name', value: 'id' }, - }, - { - kind: 'FragmentSpread', - name: { kind: 'Name', value: 'WatchCard' }, - }, - ], - }, + kind: 'FragmentSpread', + name: { kind: 'Name', value: 'CardMedia' }, }, ], }, @@ -8447,7 +8658,7 @@ export const AuthWatchedListDocument = { }, { kind: 'FragmentDefinition', - name: { kind: 'Name', value: 'WatchCard' }, + name: { kind: 'Name', value: 'CardMedia' }, typeCondition: { kind: 'NamedType', name: { kind: 'Name', value: 'Media' }, @@ -8479,7 +8690,6 @@ export const AuthWatchedListDocument = { ], }, }, - { kind: 'Field', name: { kind: 'Name', value: 'bannerImage' } }, { kind: 'FragmentSpread', name: { kind: 'Name', value: 'MediaUnitStatsMedia' }, @@ -8489,8 +8699,8 @@ export const AuthWatchedListDocument = { }, ], } as unknown as DocumentNode< - AuthWatchedListQuery, - AuthWatchedListQueryVariables + UpcomingNextSeasonQuery, + UpcomingNextSeasonQueryVariables >; export const InfoDetailsScreenDocument = { kind: 'Document', diff --git a/src/hooks/use-watched.tsx b/src/hooks/use-watched.tsx new file mode 100644 index 0000000..82da771 --- /dev/null +++ b/src/hooks/use-watched.tsx @@ -0,0 +1,169 @@ +import type { VariablesOf } from '@graphql-typed-document-node/core'; +import { useQuery } from '@tanstack/react-query'; + +import { graphql } from '@/gql'; +import { MediaListSort, MediaListStatus, MediaType } from '@/gql/graphql'; +import anilistClient from '@/services/anilist'; +import { getWatchedEpisodes } from '@/storage/episode'; +import { getProvider } from '@/storage/provider'; + +const document = graphql(` + query WatchedList($id_in: [Int], $perPage: Int = 10, $page: Int = 1) { + Page(page: $page, perPage: $perPage) { + pageInfo { + total + perPage + currentPage + lastPage + hasNextPage + } + + media(id_in: $id_in) { + id + ...WatchCard + ...CardMedia + } + } + } +`); + +const authDocument = graphql(` + query AuthWatchedList( + $userId: Int + $userName: String + $status_in: [MediaListStatus] + $type: MediaType + $sort: [MediaListSort] + $perPage: Int = 10 + $page: Int = 1 + ) { + Page(page: $page, perPage: $perPage) { + pageInfo { + total + perPage + currentPage + lastPage + hasNextPage + } + + mediaList( + userId: $userId + userName: $userName + status_in: $status_in + type: $type + sort: $sort + ) { + progress + media { + id + ...WatchCard + ...CardMedia + } + } + } + } +`); + +const getMedia = async (variables: VariablesOf) => { + return anilistClient.request(document, variables); +}; + +const getAuthMedia = async (variables: VariablesOf) => { + return anilistClient.request(authDocument, variables); +}; + +export const useWatched = (limit = 15) => { + return useQuery(['watched-list', limit], async () => { + const provider = getProvider('anilist'); + + const watchedEpisodes = getWatchedEpisodes(limit); + + const shouldUseAnilistData = !!provider?.data?.id; + + if (!shouldUseAnilistData) { + const mediaIds = watchedEpisodes.map( + (watchedEpisode) => watchedEpisode.mediaId + ); + + const anilistMedia = await getMedia({ + id_in: mediaIds, + perPage: limit || 500, + }); + + if (!anilistMedia?.Page?.media) return []; + + return watchedEpisodes + .map((episode) => { + const media = anilistMedia.Page!.media!.find( + (media) => media?.id === episode.mediaId + ); + + if (!media) return null; + + return { + media, + watchedData: { + number: episode.episode?.number, + title: episode.episode?.title || undefined, + thumbnail: episode.episode?.thumbnail || undefined, + }, + }; + }) + .filter(Boolean); + } + + const watchingList = await getAuthMedia({ + userId: provider.data.id as number, + userName: provider.data.name, + status_in: [MediaListStatus.Current], + type: MediaType.Anime, + sort: [MediaListSort.UpdatedTimeDesc], + perPage: limit || 500, + }); + + if (!watchingList?.Page?.mediaList) return []; + + return watchingList.Page.mediaList + .filter(Boolean) + .map((entry) => { + if (!entry.media) return null; + + const watchedEpisode = watchedEpisodes.find( + (watchedEpisode) => watchedEpisode.mediaId === entry.media!.id + ); + + if (!watchedEpisode) + return { + media: entry.media, + watchedData: { + number: entry.progress || 0, + title: undefined, + thumbnail: undefined, + }, + }; + + if ( + parseInt(watchedEpisode.episode?.number!, 10) >= (entry.progress || 0) + ) { + return { + media: entry.media, + watchedData: { + number: watchedEpisode.episode?.number, + title: watchedEpisode.episode?.title || undefined, + thumbnail: watchedEpisode.episode?.thumbnail || undefined, + }, + }; + } + + return { + media: entry.media, + watchedData: { + title: undefined, + thumbnail: undefined, + number: entry.progress || 0, + }, + }; + }) + .filter(Boolean); + }); +}; diff --git a/src/navigation/anime-navigator.tsx b/src/navigation/anime-navigator.tsx index 93d502d..15e5fd6 100644 --- a/src/navigation/anime-navigator.tsx +++ b/src/navigation/anime-navigator.tsx @@ -3,6 +3,7 @@ import React from 'react'; import { AnimeHomeScreen } from '@/screens'; import { AnimeDetailsScreen } from '@/screens/anime/details/screen'; +import RecentlyWatchedScreen from '@/screens/anime/recently-watched/screen'; import { AnimeWatchScreen } from '@/screens/anime/watch/screen'; export type AnimeParamsList = { @@ -15,6 +16,7 @@ export type AnimeParamsList = { mediaId: number; episodeId: string; }; + RecentlyWatched: undefined; }; const Stack = createNativeStackNavigator(); @@ -39,6 +41,11 @@ export const AnimeNavigator = () => ( name="AnimeWatch" component={AnimeWatchScreen} /> + ); diff --git a/src/screens/anime/components/watched-list.tsx b/src/screens/anime/components/watched-list.tsx index 24c54cc..f2948cc 100644 --- a/src/screens/anime/components/watched-list.tsx +++ b/src/screens/anime/components/watched-list.tsx @@ -1,167 +1,44 @@ -import type { VariablesOf } from '@graphql-typed-document-node/core'; +import { useNavigation } from '@react-navigation/native'; import { FlashList } from '@shopify/flash-list'; -import { useQuery } from '@tanstack/react-query'; import React, { useMemo } from 'react'; -import { graphql } from '@/gql'; -import { MediaListSort, MediaListStatus, MediaType } from '@/gql/graphql'; import useScreenSize from '@/hooks/use-screen-size'; -import anilistClient from '@/services/anilist'; +import { useWatched } from '@/hooks/use-watched'; import { getWatchedEpisodes } from '@/storage/episode'; -import { getProvider } from '@/storage/provider'; -import { Text, View } from '@/ui'; +import { Button, Text, View } from '@/ui'; import Skeleton, { SkeletonItem } from '@/ui/core/skeleton'; import WatchCard, { WATCH_CARD_WIDTH } from './watch-card'; -const document = graphql(` - query WatchedList($id_in: [Int]) { - Page(page: 1, perPage: 10) { - media(id_in: $id_in) { - id - ...WatchCard - } - } - } -`); - -const authDocument = graphql(` - query AuthWatchedList( - $userId: Int - $userName: String - $status_in: [MediaListStatus] - $type: MediaType - $sort: [MediaListSort] - ) { - Page(page: 1, perPage: 10) { - mediaList( - userId: $userId - userName: $userName - status_in: $status_in - type: $type - sort: $sort - ) { - progress - media { - id - ...WatchCard - } - } - } - } -`); - const SPACE_BETWEEN = 8; -const getMedia = async (variables: VariablesOf) => { - return anilistClient.request(document, variables); -}; - -const getAuthMedia = async (variables: VariablesOf) => { - return anilistClient.request(authDocument, variables); -}; - -// What the fuck I just wrote? const WatchedList = () => { const watchedEpisodes = useMemo(getWatchedEpisodes, []); - const { data, isLoading } = useQuery(['watched-list'], async () => { - const provider = getProvider('anilist'); - - const shouldUseAnilistData = !!provider?.data?.id; - - if (!shouldUseAnilistData) { - const mediaIds = watchedEpisodes.map( - (watchedEpisode) => watchedEpisode.mediaId - ); - - const anilistMedia = await getMedia({ - id_in: mediaIds, - }); - - if (!anilistMedia?.Page?.media) return []; + const { data, isLoading } = useWatched(15); - return watchedEpisodes - .map((episode) => { - const media = anilistMedia.Page!.media!.find( - (media) => media?.id === episode.mediaId - ); - - if (!media) return null; - - return { - media, - watchedData: { - number: episode.episode?.number, - title: episode.episode?.title || undefined, - thumbnail: episode.episode?.thumbnail || undefined, - }, - }; - }) - .filter(Boolean); - } - - const watchingList = await getAuthMedia({ - userId: provider.data.id as number, - userName: provider.data.name, - status_in: [MediaListStatus.Current], - type: MediaType.Anime, - sort: [MediaListSort.UpdatedTimeDesc], - }); - - if (!watchingList?.Page?.mediaList) return []; - - return watchingList.Page.mediaList - .filter(Boolean) - .map((entry) => { - if (!entry.media) return null; - - const watchedEpisode = watchedEpisodes.find( - (watchedEpisode) => watchedEpisode.mediaId === entry.media!.id - ); - - if (!watchedEpisode) - return { - media: entry.media, - watchedData: { - number: entry.progress || 0, - title: undefined, - thumbnail: undefined, - }, - }; - - if ( - parseInt(watchedEpisode.episode?.number!, 10) >= (entry.progress || 0) - ) { - return { - media: entry.media, - watchedData: { - number: watchedEpisode.episode?.number, - title: watchedEpisode.episode?.title || undefined, - thumbnail: watchedEpisode.episode?.thumbnail || undefined, - }, - }; - } - - return { - media: entry.media, - watchedData: { - title: undefined, - thumbnail: undefined, - number: entry.progress || 0, - }, - }; - }) - .filter(Boolean); - }); + const navigation = useNavigation(); if (!watchedEpisodes.length) return null; return ( - - Recently watched - + + + Recently watched + + + + {isLoading ? ( diff --git a/src/screens/anime/recently-watched/screen.tsx b/src/screens/anime/recently-watched/screen.tsx new file mode 100644 index 0000000..f03f050 --- /dev/null +++ b/src/screens/anime/recently-watched/screen.tsx @@ -0,0 +1,78 @@ +import { FlashList } from '@shopify/flash-list'; +import React from 'react'; + +import { useFragment } from '@/gql'; +import useScreenSize from '@/hooks/use-screen-size'; +import { useWatched } from '@/hooks/use-watched'; +import { ActivityIndicator, Text, View } from '@/ui'; +import { Card, CardFragment } from '@/ui/card'; +import colors from '@/ui/theme/colors'; + +const SPACE_BETWEEN = 32; +const CONTAINER_PADDING = 16; +const LIST_PADDING = 16; + +const RecentlyWatchedScreen = () => { + const { width } = useScreenSize(); + + const { data, isLoading } = useWatched(0); + + if (isLoading) + return ( + + + + ); + + if (!data?.length) { + return ( + + You haven't watched anything yet? + + ); + } + + return ( + + + Recently watched + + + { + return ( + + + + ); + }} + estimatedItemSize={294} + keyExtractor={(item) => + // eslint-disable-next-line react-hooks/rules-of-hooks + useFragment(CardFragment, item.media).id.toString() + } + /> + + ); +}; + +export default RecentlyWatchedScreen;