Skip to content

Commit

Permalink
feat: add to list (#41)
Browse files Browse the repository at this point in the history
  • Loading branch information
hoangvu12 authored Jan 9, 2024
1 parent 1df1a6b commit c2c4366
Show file tree
Hide file tree
Showing 18 changed files with 1,032 additions and 4 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
"@graphql-typed-document-node/core": "^3.2.0",
"@jonasmerlin/react-native-markdown-display": "github:jonasmerlin/react-native-markdown-display",
"@plussub/srt-vtt-parser": "^1.1.0",
"@react-native-community/datetimepicker": "7.2.0",
"@react-native-community/viewpager": "^5.0.11",
"@react-native-picker/picker": "2.4.10",
"@react-navigation/bottom-tabs": "^6.5.7",
Expand Down
9 changes: 9 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 19 additions & 3 deletions src/gql/gql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ const documents = {
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':
types.SaveMediaListEntryDocument,
'\n mutation DeleteMediaListEntry($id: Int) {\n DeleteMediaListEntry(id: $id) {\n deleted\n }\n }\n':
types.DeleteMediaListEntryDocument,
'\n query AiringScheduleScreen($airingAt_greater: Int, $airingAt_lesser: Int) {\n Page(page: 1, perPage: 50) {\n airingSchedules(\n airingAt_greater: $airingAt_greater\n airingAt_lesser: $airingAt_lesser\n sort: [TIME_DESC]\n ) {\n airingAt\n media {\n id\n isAdult\n ...DetailsCard\n }\n episode\n }\n }\n }\n':
types.AiringScheduleScreenDocument,
'\n query AiringSchedule($airingAt_greater: Int, $airingAt_lesser: Int) {\n Page(page: 1, perPage: 20) {\n airingSchedules(\n airingAt_greater: $airingAt_greater\n airingAt_lesser: $airingAt_lesser\n sort: [TIME_DESC]\n ) {\n media {\n isAdult\n ...CardMedia\n }\n }\n }\n }\n':
Expand All @@ -31,7 +33,9 @@ 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 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':
'\n query AddToListQuery($mediaId: Int) {\n Media(id: $mediaId) {\n mediaListEntry {\n id\n status\n score(format: POINT_10)\n progress\n repeat\n notes\n startedAt {\n year\n month\n day\n }\n completedAt {\n year\n month\n day\n }\n private\n }\n episodes\n }\n }\n':
types.AddToListQueryDocument,
'\n fragment DetailsHeaderMedia on Media {\n id\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':
types.InfoDetailsScreenDocument,
Expand Down Expand Up @@ -127,6 +131,12 @@ export function graphql(
export function graphql(
source: '\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'
): (typeof documents)['\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'];
/**
* The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients.
*/
export function graphql(
source: '\n mutation DeleteMediaListEntry($id: Int) {\n DeleteMediaListEntry(id: $id) {\n deleted\n }\n }\n'
): (typeof documents)['\n mutation DeleteMediaListEntry($id: Int) {\n DeleteMediaListEntry(id: $id) {\n deleted\n }\n }\n'];
/**
* The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients.
*/
Expand Down Expand Up @@ -161,8 +171,14 @@ export function graphql(
* The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients.
*/
export function graphql(
source: '\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'
): (typeof documents)['\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'];
source: '\n query AddToListQuery($mediaId: Int) {\n Media(id: $mediaId) {\n mediaListEntry {\n id\n status\n score(format: POINT_10)\n progress\n repeat\n notes\n startedAt {\n year\n month\n day\n }\n completedAt {\n year\n month\n day\n }\n private\n }\n episodes\n }\n }\n'
): (typeof documents)['\n query AddToListQuery($mediaId: Int) {\n Media(id: $mediaId) {\n mediaListEntry {\n id\n status\n score(format: POINT_10)\n progress\n repeat\n notes\n startedAt {\n year\n month\n day\n }\n completedAt {\n year\n month\n day\n }\n private\n }\n episodes\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 fragment DetailsHeaderMedia on Media {\n id\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'
): (typeof documents)['\n fragment DetailsHeaderMedia on Media {\n id\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'];
/**
* The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients.
*/
Expand Down
219 changes: 219 additions & 0 deletions src/gql/graphql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4683,6 +4683,18 @@ export type SaveMediaListEntryMutation = {
} | null;
};

export type DeleteMediaListEntryMutationVariables = Exact<{
id?: InputMaybe<Scalars['Int']['input']>;
}>;

export type DeleteMediaListEntryMutation = {
__typename?: 'Mutation';
DeleteMediaListEntry?: {
__typename?: 'Deleted';
deleted?: boolean | null;
} | null;
};

export type AiringScheduleScreenQueryVariables = Exact<{
airingAt_greater?: InputMaybe<Scalars['Int']['input']>;
airingAt_lesser?: InputMaybe<Scalars['Int']['input']>;
Expand Down Expand Up @@ -4773,8 +4785,43 @@ export type WatchCardFragment = ({
};
}) & { ' $fragmentName'?: 'WatchCardFragment' };

export type AddToListQueryQueryVariables = Exact<{
mediaId?: InputMaybe<Scalars['Int']['input']>;
}>;

export type AddToListQueryQuery = {
__typename?: 'Query';
Media?: {
__typename?: 'Media';
episodes?: number | null;
mediaListEntry?: {
__typename?: 'MediaList';
id: number;
status?: MediaListStatus | null;
score?: number | null;
progress?: number | null;
repeat?: number | null;
notes?: string | null;
private?: boolean | null;
startedAt?: {
__typename?: 'FuzzyDate';
year?: number | null;
month?: number | null;
day?: number | null;
} | null;
completedAt?: {
__typename?: 'FuzzyDate';
year?: number | null;
month?: number | null;
day?: number | null;
} | null;
} | null;
} | null;
};

export type DetailsHeaderMediaFragment = {
__typename?: 'Media';
id: number;
bannerImage?: string | null;
genres?: Array<string | null> | null;
favourites?: number | null;
Expand Down Expand Up @@ -5497,6 +5544,7 @@ export const DetailsHeaderMediaFragmentDoc = {
selectionSet: {
kind: 'SelectionSet',
selections: [
{ kind: 'Field', name: { kind: 'Name', value: 'id' } },
{
kind: 'Field',
name: { kind: 'Name', value: 'title' },
Expand Down Expand Up @@ -8590,6 +8638,51 @@ export const SaveMediaListEntryDocument = {
SaveMediaListEntryMutation,
SaveMediaListEntryMutationVariables
>;
export const DeleteMediaListEntryDocument = {
kind: 'Document',
definitions: [
{
kind: 'OperationDefinition',
operation: 'mutation',
name: { kind: 'Name', value: 'DeleteMediaListEntry' },
variableDefinitions: [
{
kind: 'VariableDefinition',
variable: { kind: 'Variable', name: { kind: 'Name', value: 'id' } },
type: { kind: 'NamedType', name: { kind: 'Name', value: 'Int' } },
},
],
selectionSet: {
kind: 'SelectionSet',
selections: [
{
kind: 'Field',
name: { kind: 'Name', value: 'DeleteMediaListEntry' },
arguments: [
{
kind: 'Argument',
name: { kind: 'Name', value: 'id' },
value: {
kind: 'Variable',
name: { kind: 'Name', value: 'id' },
},
},
],
selectionSet: {
kind: 'SelectionSet',
selections: [
{ kind: 'Field', name: { kind: 'Name', value: 'deleted' } },
],
},
},
],
},
},
],
} as unknown as DocumentNode<
DeleteMediaListEntryMutation,
DeleteMediaListEntryMutationVariables
>;
export const AiringScheduleScreenDocument = {
kind: 'Document',
definitions: [
Expand Down Expand Up @@ -9323,6 +9416,131 @@ export const UpcomingNextSeasonDocument = {
UpcomingNextSeasonQuery,
UpcomingNextSeasonQueryVariables
>;
export const AddToListQueryDocument = {
kind: 'Document',
definitions: [
{
kind: 'OperationDefinition',
operation: 'query',
name: { kind: 'Name', value: 'AddToListQuery' },
variableDefinitions: [
{
kind: 'VariableDefinition',
variable: {
kind: 'Variable',
name: { kind: 'Name', value: 'mediaId' },
},
type: { kind: 'NamedType', name: { kind: 'Name', value: 'Int' } },
},
],
selectionSet: {
kind: 'SelectionSet',
selections: [
{
kind: 'Field',
name: { kind: 'Name', value: 'Media' },
arguments: [
{
kind: 'Argument',
name: { kind: 'Name', value: 'id' },
value: {
kind: 'Variable',
name: { kind: 'Name', value: 'mediaId' },
},
},
],
selectionSet: {
kind: 'SelectionSet',
selections: [
{
kind: 'Field',
name: { kind: 'Name', value: 'mediaListEntry' },
selectionSet: {
kind: 'SelectionSet',
selections: [
{ kind: 'Field', name: { kind: 'Name', value: 'id' } },
{
kind: 'Field',
name: { kind: 'Name', value: 'status' },
},
{
kind: 'Field',
name: { kind: 'Name', value: 'score' },
arguments: [
{
kind: 'Argument',
name: { kind: 'Name', value: 'format' },
value: { kind: 'EnumValue', value: 'POINT_10' },
},
],
},
{
kind: 'Field',
name: { kind: 'Name', value: 'progress' },
},
{
kind: 'Field',
name: { kind: 'Name', value: 'repeat' },
},
{ kind: 'Field', name: { kind: 'Name', value: 'notes' } },
{
kind: 'Field',
name: { kind: 'Name', value: 'startedAt' },
selectionSet: {
kind: 'SelectionSet',
selections: [
{
kind: 'Field',
name: { kind: 'Name', value: 'year' },
},
{
kind: 'Field',
name: { kind: 'Name', value: 'month' },
},
{
kind: 'Field',
name: { kind: 'Name', value: 'day' },
},
],
},
},
{
kind: 'Field',
name: { kind: 'Name', value: 'completedAt' },
selectionSet: {
kind: 'SelectionSet',
selections: [
{
kind: 'Field',
name: { kind: 'Name', value: 'year' },
},
{
kind: 'Field',
name: { kind: 'Name', value: 'month' },
},
{
kind: 'Field',
name: { kind: 'Name', value: 'day' },
},
],
},
},
{
kind: 'Field',
name: { kind: 'Name', value: 'private' },
},
],
},
},
{ kind: 'Field', name: { kind: 'Name', value: 'episodes' } },
],
},
},
],
},
},
],
} as unknown as DocumentNode<AddToListQueryQuery, AddToListQueryQueryVariables>;
export const InfoDetailsScreenDocument = {
kind: 'Document',
definitions: [
Expand Down Expand Up @@ -9914,6 +10132,7 @@ export const InfoDetailsScreenDocument = {
selectionSet: {
kind: 'SelectionSet',
selections: [
{ kind: 'Field', name: { kind: 'Name', value: 'id' } },
{
kind: 'Field',
name: { kind: 'Name', value: 'title' },
Expand Down
17 changes: 17 additions & 0 deletions src/providers/anilist.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,14 @@ const saveMediaListEntry = graphql(`
}
`);

const deleteMediaListEntry = graphql(`
mutation DeleteMediaListEntry($id: Int) {
DeleteMediaListEntry(id: $id) {
deleted
}
}
`);

export default class AnilistProvider extends Provider {
constructor() {
super({
Expand Down Expand Up @@ -127,4 +135,13 @@ export default class AnilistProvider extends Provider {
...entry,
});
}

deleteEntry(
_: { malId: number | undefined; anilistId: number },
entryId: number
): Promise<any> {
return anilistClient.request(deleteMediaListEntry, {
id: entryId,
});
}
}
10 changes: 10 additions & 0 deletions src/providers/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,14 @@ export default class Provider {
): Promise<any> {
throw new Error('Method not implemented.');
}

deleteEntry(
ids: {
malId: number;
anilistId: number;
},
entryId: number
): Promise<any> {
throw new Error('Method not implemented.');
}
}
Loading

0 comments on commit c2c4366

Please sign in to comment.