From c1e92b3256558017ce5f16b6c1d4b7d0182f08ae Mon Sep 17 00:00:00 2001 From: schroda <50052685+schroda@users.noreply.github.com> Date: Tue, 9 Jul 2024 00:39:41 +0200 Subject: [PATCH] Extract info gql fragments --- src/components/util/WebUIUpdateChecker.tsx | 2 +- src/lib/graphql/Fragments.ts | 33 --------------- src/lib/graphql/fragments/InfoFragments.ts | 42 +++++++++++++++++++ src/lib/graphql/generated/graphql.ts | 16 +++---- .../graphql/mutations/ServerInfoMutation.ts | 2 +- src/lib/graphql/queries/ServerInfoQuery.ts | 2 +- .../subscriptions/ServerInfoSubscription.ts | 2 +- 7 files changed, 54 insertions(+), 45 deletions(-) create mode 100644 src/lib/graphql/fragments/InfoFragments.ts diff --git a/src/components/util/WebUIUpdateChecker.tsx b/src/components/util/WebUIUpdateChecker.tsx index 256da58b..85987523 100644 --- a/src/components/util/WebUIUpdateChecker.tsx +++ b/src/components/util/WebUIUpdateChecker.tsx @@ -19,7 +19,7 @@ import { UpdateState, WebUiChannel, WebUiUpdateStatus } from '@/lib/graphql/gene import { useLocalStorage } from '@/util/useStorage.tsx'; import { requestManager } from '@/lib/requests/RequestManager.ts'; import { makeToast } from '@/components/util/Toast.tsx'; -import { ABOUT_WEBUI, WEBUI_UPDATE_CHECK } from '@/lib/graphql/Fragments.ts'; +import { ABOUT_WEBUI, WEBUI_UPDATE_CHECK } from '@/lib/graphql/fragments/InfoFragments.ts'; import { VersionUpdateInfoDialog } from '@/components/util/VersionUpdateInfoDialog.tsx'; import { useUpdateChecker } from '@/util/useUpdateChecker'; import { useMetadataServerSettings } from '@/lib/metadata/metadataServerSettings.ts'; diff --git a/src/lib/graphql/Fragments.ts b/src/lib/graphql/Fragments.ts index b91ba49c..2fcaf7b9 100644 --- a/src/lib/graphql/Fragments.ts +++ b/src/lib/graphql/Fragments.ts @@ -23,36 +23,3 @@ export const GLOBAL_METADATA = gql` value } `; - -export const ABOUT_WEBUI = gql` - fragment ABOUT_WEBUI on AboutWebUI { - channel - tag - } -`; - -export const WEBUI_UPDATE_CHECK = gql` - fragment WEBUI_UPDATE_CHECK on WebUIUpdateCheck { - channel - tag - updateAvailable - } -`; - -export const WEBUI_UPDATE_INFO = gql` - fragment WEBUI_UPDATE_INFO on WebUIUpdateInfo { - channel - tag - } -`; - -export const WEBUI_UPDATE_STATUS = gql` - ${WEBUI_UPDATE_INFO} - fragment WEBUI_UPDATE_STATUS on WebUIUpdateStatus { - info { - ...WEBUI_UPDATE_INFO - } - progress - state - } -`; diff --git a/src/lib/graphql/fragments/InfoFragments.ts b/src/lib/graphql/fragments/InfoFragments.ts new file mode 100644 index 00000000..f4b75784 --- /dev/null +++ b/src/lib/graphql/fragments/InfoFragments.ts @@ -0,0 +1,42 @@ +/* + * 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'; + +export const ABOUT_WEBUI = gql` + fragment ABOUT_WEBUI on AboutWebUI { + channel + tag + } +`; + +export const WEBUI_UPDATE_CHECK = gql` + fragment WEBUI_UPDATE_CHECK on WebUIUpdateCheck { + channel + tag + updateAvailable + } +`; + +export const WEBUI_UPDATE_INFO = gql` + fragment WEBUI_UPDATE_INFO on WebUIUpdateInfo { + channel + tag + } +`; + +export const WEBUI_UPDATE_STATUS = gql` + ${WEBUI_UPDATE_INFO} + fragment WEBUI_UPDATE_STATUS on WebUIUpdateStatus { + info { + ...WEBUI_UPDATE_INFO + } + progress + state + } +`; diff --git a/src/lib/graphql/generated/graphql.ts b/src/lib/graphql/generated/graphql.ts index c574d65b..94df67bb 100644 --- a/src/lib/graphql/generated/graphql.ts +++ b/src/lib/graphql/generated/graphql.ts @@ -2588,14 +2588,6 @@ export type PageInfoFragment = { __typename?: 'PageInfo', endCursor?: string | n export type GlobalMetadataFragment = { __typename?: 'GlobalMetaType', key: string, value: string }; -export type AboutWebuiFragment = { __typename?: 'AboutWebUI', channel: string, tag: string }; - -export type WebuiUpdateCheckFragment = { __typename?: 'WebUIUpdateCheck', channel: string, tag: string, updateAvailable: boolean }; - -export type WebuiUpdateInfoFragment = { __typename?: 'WebUIUpdateInfo', channel: string, tag: string }; - -export type WebuiUpdateStatusFragment = { __typename?: 'WebUIUpdateStatus', progress: number, state: UpdateState, info: { __typename?: 'WebUIUpdateInfo', channel: string, tag: string } }; - export type CategoryBaseFieldsFragment = { __typename?: 'CategoryType', id: number, name: string, default: boolean, order: number }; export type CategoryLibraryFieldsFragment = { __typename?: 'CategoryType', id: number, name: string, default: boolean, order: number, mangas: { __typename?: 'MangaNodeList', totalCount: number } }; @@ -2616,6 +2608,14 @@ export type DownloadStatusFieldsFragment = { __typename?: 'DownloadStatus', stat export type ExtensionListFieldsFragment = { __typename?: 'ExtensionType', pkgName: string, name: string, lang: string, versionCode: number, versionName: string, iconUrl: string, repo?: string | null, isNsfw: boolean, isInstalled: boolean, isObsolete: boolean, hasUpdate: boolean }; +export type AboutWebuiFragment = { __typename?: 'AboutWebUI', channel: string, tag: string }; + +export type WebuiUpdateCheckFragment = { __typename?: 'WebUIUpdateCheck', channel: string, tag: string, updateAvailable: boolean }; + +export type WebuiUpdateInfoFragment = { __typename?: 'WebUIUpdateInfo', channel: string, tag: string }; + +export type WebuiUpdateStatusFragment = { __typename?: 'WebUIUpdateStatus', progress: number, state: UpdateState, info: { __typename?: 'WebUIUpdateInfo', channel: string, tag: string } }; + export type MangaBaseFieldsFragment = { __typename?: 'MangaType', id: number, title: string, thumbnailUrl?: string | null, thumbnailUrlLastFetched?: string | null, inLibrary: boolean, initialized: boolean, sourceId: string }; export type MangaChapterStatFieldsFragment = { __typename?: 'MangaType', id: number, unreadCount: number, downloadCount: number, bookmarkCount: number, chapters: { __typename?: 'ChapterNodeList', totalCount: number } }; diff --git a/src/lib/graphql/mutations/ServerInfoMutation.ts b/src/lib/graphql/mutations/ServerInfoMutation.ts index 96e60d16..fce42c7a 100644 --- a/src/lib/graphql/mutations/ServerInfoMutation.ts +++ b/src/lib/graphql/mutations/ServerInfoMutation.ts @@ -7,7 +7,7 @@ */ import gql from 'graphql-tag'; -import { WEBUI_UPDATE_INFO, WEBUI_UPDATE_STATUS } from '@/lib/graphql/Fragments'; +import { WEBUI_UPDATE_INFO, WEBUI_UPDATE_STATUS } from '@/lib/graphql/fragments/InfoFragments.ts'; export const UPDATE_WEBUI = gql` ${WEBUI_UPDATE_STATUS} diff --git a/src/lib/graphql/queries/ServerInfoQuery.ts b/src/lib/graphql/queries/ServerInfoQuery.ts index 355bdc19..6756fe36 100644 --- a/src/lib/graphql/queries/ServerInfoQuery.ts +++ b/src/lib/graphql/queries/ServerInfoQuery.ts @@ -7,7 +7,7 @@ */ import gql from 'graphql-tag'; -import { ABOUT_WEBUI, WEBUI_UPDATE_CHECK, WEBUI_UPDATE_STATUS } from '@/lib/graphql/Fragments'; +import { ABOUT_WEBUI, WEBUI_UPDATE_CHECK, WEBUI_UPDATE_STATUS } from '@/lib/graphql/fragments/InfoFragments.ts'; export const GET_ABOUT = gql` ${ABOUT_WEBUI} diff --git a/src/lib/graphql/subscriptions/ServerInfoSubscription.ts b/src/lib/graphql/subscriptions/ServerInfoSubscription.ts index 740a6f58..a231bc2c 100644 --- a/src/lib/graphql/subscriptions/ServerInfoSubscription.ts +++ b/src/lib/graphql/subscriptions/ServerInfoSubscription.ts @@ -7,7 +7,7 @@ */ import gql from 'graphql-tag'; -import { WEBUI_UPDATE_STATUS } from '@/lib/graphql/Fragments'; +import { WEBUI_UPDATE_STATUS } from '@/lib/graphql/fragments/InfoFragments.ts'; export const WEBUI_UPDATE_SUBSCRIPTION = gql` ${WEBUI_UPDATE_STATUS}