2023-08-05 01:03:40 +02:00
|
|
|
/*
|
|
|
|
|
* Copyright (C) Contributors to the Suwayomi project
|
|
|
|
|
*
|
|
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
|
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
import gql from 'graphql-tag';
|
2024-07-02 16:20:28 +02:00
|
|
|
import { CHAPTER_LIST_FIELDS } from '@/lib/graphql/fragments/ChapterFragments.ts';
|
2024-07-04 22:00:39 +02:00
|
|
|
import { TRACK_RECORD_BIND_FIELDS } from '@/lib/graphql/fragments/TrackRecordFragments.ts';
|
2024-07-26 13:42:33 +02:00
|
|
|
import { MANGA_CHAPTER_NODE_FIELDS, MANGA_CHAPTER_STAT_FIELDS } from '@/lib/graphql/fragments/MangaFragments.ts';
|
2023-08-05 01:03:40 +02:00
|
|
|
|
|
|
|
|
export const DELETE_CHAPTER_METADATA = gql`
|
|
|
|
|
mutation DELETE_CHAPTER_METADATA($input: DeleteChapterMetaInput!) {
|
|
|
|
|
deleteChapterMeta(input: $input) {
|
|
|
|
|
meta {
|
|
|
|
|
key
|
|
|
|
|
value
|
|
|
|
|
chapter {
|
2023-11-24 03:17:49 +01:00
|
|
|
id
|
|
|
|
|
meta {
|
|
|
|
|
key
|
|
|
|
|
value
|
|
|
|
|
}
|
2023-08-05 01:03:40 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
chapter {
|
2023-11-24 03:17:49 +01:00
|
|
|
id
|
|
|
|
|
meta {
|
|
|
|
|
key
|
|
|
|
|
value
|
|
|
|
|
}
|
2023-08-05 01:03:40 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
`;
|
|
|
|
|
|
|
|
|
|
// makes the server fetch and return the pages of a chapter
|
|
|
|
|
export const GET_CHAPTER_PAGES_FETCH = gql`
|
|
|
|
|
mutation GET_CHAPTER_PAGES_FETCH($input: FetchChapterPagesInput!) {
|
|
|
|
|
fetchChapterPages(input: $input) {
|
|
|
|
|
chapter {
|
2023-11-24 03:17:49 +01:00
|
|
|
id
|
|
|
|
|
pageCount
|
2023-08-05 01:03:40 +02:00
|
|
|
}
|
|
|
|
|
pages
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
`;
|
|
|
|
|
|
|
|
|
|
// makes the server fetch and return the chapters of the manga
|
|
|
|
|
export const GET_MANGA_CHAPTERS_FETCH = gql`
|
2024-07-02 16:20:28 +02:00
|
|
|
${CHAPTER_LIST_FIELDS}
|
2024-07-26 13:42:33 +02:00
|
|
|
${MANGA_CHAPTER_STAT_FIELDS}
|
|
|
|
|
${MANGA_CHAPTER_NODE_FIELDS}
|
2024-07-02 16:20:28 +02:00
|
|
|
|
2023-08-05 01:03:40 +02:00
|
|
|
mutation GET_MANGA_CHAPTERS_FETCH($input: FetchChaptersInput!) {
|
|
|
|
|
fetchChapters(input: $input) {
|
|
|
|
|
chapters {
|
2024-07-02 16:20:28 +02:00
|
|
|
...CHAPTER_LIST_FIELDS
|
2024-01-29 20:55:49 +01:00
|
|
|
manga {
|
|
|
|
|
id
|
2024-07-26 13:42:33 +02:00
|
|
|
...MANGA_CHAPTER_STAT_FIELDS
|
|
|
|
|
...MANGA_CHAPTER_NODE_FIELDS
|
2024-01-29 20:55:49 +01:00
|
|
|
}
|
2023-08-05 01:03:40 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
`;
|
|
|
|
|
|
|
|
|
|
export const SET_CHAPTER_METADATA = gql`
|
|
|
|
|
mutation SET_CHAPTER_METADATA($input: SetChapterMetaInput!) {
|
|
|
|
|
setChapterMeta(input: $input) {
|
|
|
|
|
meta {
|
|
|
|
|
key
|
|
|
|
|
value
|
|
|
|
|
chapter {
|
2023-11-24 03:17:49 +01:00
|
|
|
id
|
|
|
|
|
meta {
|
|
|
|
|
key
|
|
|
|
|
value
|
|
|
|
|
}
|
2023-08-05 01:03:40 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
`;
|
|
|
|
|
|
|
|
|
|
export const UPDATE_CHAPTER = gql`
|
2024-07-04 22:00:39 +02:00
|
|
|
${TRACK_RECORD_BIND_FIELDS}
|
|
|
|
|
|
2023-11-24 03:17:49 +01:00
|
|
|
mutation UPDATE_CHAPTER(
|
|
|
|
|
$input: UpdateChapterInput!
|
|
|
|
|
$getBookmarked: Boolean!
|
|
|
|
|
$getRead: Boolean!
|
|
|
|
|
$getLastPageRead: Boolean!
|
2023-12-05 22:20:13 +01:00
|
|
|
$chapterIdToDelete: Int!
|
2023-11-24 03:17:49 +01:00
|
|
|
$deleteChapter: Boolean!
|
2024-04-01 01:22:49 +02:00
|
|
|
$mangaId: Int!
|
|
|
|
|
$trackProgress: Boolean!
|
2023-11-24 03:17:49 +01:00
|
|
|
) {
|
2023-08-05 01:03:40 +02:00
|
|
|
updateChapter(input: $input) {
|
|
|
|
|
chapter {
|
2023-11-24 03:17:49 +01:00
|
|
|
id
|
|
|
|
|
isBookmarked @include(if: $getBookmarked)
|
|
|
|
|
isRead @include(if: $getRead)
|
|
|
|
|
lastReadAt @include(if: $getRead)
|
|
|
|
|
lastPageRead @include(if: $getLastPageRead)
|
|
|
|
|
manga @include(if: $getRead) {
|
|
|
|
|
id
|
|
|
|
|
unreadCount
|
|
|
|
|
lastReadChapter {
|
|
|
|
|
id
|
|
|
|
|
}
|
2024-01-11 03:53:06 +01:00
|
|
|
latestReadChapter {
|
|
|
|
|
id
|
|
|
|
|
}
|
2024-04-01 00:57:47 +02:00
|
|
|
firstUnreadChapter {
|
|
|
|
|
id
|
|
|
|
|
}
|
2023-11-24 03:17:49 +01:00
|
|
|
}
|
2024-04-01 01:12:26 +02:00
|
|
|
manga @include(if: $getBookmarked) {
|
|
|
|
|
id
|
|
|
|
|
bookmarkCount
|
|
|
|
|
}
|
2023-11-24 03:17:49 +01:00
|
|
|
}
|
|
|
|
|
}
|
2023-12-05 22:20:13 +01:00
|
|
|
deleteDownloadedChapter(input: { id: $chapterIdToDelete }) @include(if: $deleteChapter) {
|
2023-11-24 03:17:49 +01:00
|
|
|
chapters {
|
|
|
|
|
id
|
|
|
|
|
isDownloaded
|
|
|
|
|
manga {
|
|
|
|
|
id
|
|
|
|
|
downloadCount
|
|
|
|
|
}
|
2023-08-05 01:03:40 +02:00
|
|
|
}
|
|
|
|
|
}
|
2024-04-01 01:22:49 +02:00
|
|
|
trackProgress(input: { mangaId: $mangaId }) @include(if: $trackProgress) {
|
|
|
|
|
trackRecords {
|
2024-07-04 22:00:39 +02:00
|
|
|
...TRACK_RECORD_BIND_FIELDS
|
2024-04-01 01:22:49 +02:00
|
|
|
}
|
|
|
|
|
}
|
2023-08-05 01:03:40 +02:00
|
|
|
}
|
|
|
|
|
`;
|
|
|
|
|
|
|
|
|
|
export const UPDATE_CHAPTERS = gql`
|
2024-07-04 22:00:39 +02:00
|
|
|
${TRACK_RECORD_BIND_FIELDS}
|
|
|
|
|
|
2023-11-24 03:17:49 +01:00
|
|
|
mutation UPDATE_CHAPTERS(
|
|
|
|
|
$input: UpdateChaptersInput!
|
|
|
|
|
$getBookmarked: Boolean!
|
|
|
|
|
$getRead: Boolean!
|
|
|
|
|
$getLastPageRead: Boolean!
|
|
|
|
|
$chapterIdsToDelete: [Int!]!
|
|
|
|
|
$deleteChapters: Boolean!
|
2024-04-20 23:15:02 +02:00
|
|
|
$mangaId: Int!
|
|
|
|
|
$trackProgress: Boolean!
|
2023-11-24 03:17:49 +01:00
|
|
|
) {
|
2023-08-05 01:03:40 +02:00
|
|
|
updateChapters(input: $input) {
|
|
|
|
|
chapters {
|
2023-11-24 03:17:49 +01:00
|
|
|
id
|
|
|
|
|
isBookmarked @include(if: $getBookmarked)
|
|
|
|
|
isRead @include(if: $getRead)
|
|
|
|
|
lastReadAt @include(if: $getRead)
|
|
|
|
|
lastPageRead @include(if: $getLastPageRead)
|
|
|
|
|
manga @include(if: $getRead) {
|
|
|
|
|
id
|
|
|
|
|
unreadCount
|
|
|
|
|
lastReadChapter {
|
|
|
|
|
id
|
|
|
|
|
}
|
2024-01-11 03:53:06 +01:00
|
|
|
latestReadChapter {
|
|
|
|
|
id
|
|
|
|
|
}
|
2024-04-01 00:57:47 +02:00
|
|
|
firstUnreadChapter {
|
|
|
|
|
id
|
|
|
|
|
}
|
2023-11-24 03:17:49 +01:00
|
|
|
}
|
2024-04-01 01:12:26 +02:00
|
|
|
manga @include(if: $getBookmarked) {
|
|
|
|
|
id
|
|
|
|
|
bookmarkCount
|
|
|
|
|
}
|
2023-08-05 01:03:40 +02:00
|
|
|
}
|
|
|
|
|
}
|
2023-11-24 03:17:49 +01:00
|
|
|
deleteDownloadedChapters(input: { ids: $chapterIdsToDelete }) @include(if: $deleteChapters) {
|
|
|
|
|
chapters {
|
|
|
|
|
id
|
|
|
|
|
isDownloaded
|
|
|
|
|
manga {
|
|
|
|
|
id
|
|
|
|
|
downloadCount
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2024-04-20 23:15:02 +02:00
|
|
|
trackProgress(input: { mangaId: $mangaId }) @include(if: $trackProgress) {
|
|
|
|
|
trackRecords {
|
2024-07-04 22:00:39 +02:00
|
|
|
...TRACK_RECORD_BIND_FIELDS
|
2024-04-20 23:15:02 +02:00
|
|
|
}
|
|
|
|
|
}
|
2023-08-05 01:03:40 +02:00
|
|
|
}
|
|
|
|
|
`;
|