Reduce requested extension data in queries
This commit is contained in:
@@ -14,14 +14,15 @@ import Avatar from '@mui/material/Avatar';
|
||||
import Typography from '@mui/material/Typography';
|
||||
import Box from '@mui/material/Box';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { PartialExtension, TranslationKey } from '@/typings';
|
||||
import { TranslationKey } from '@/typings';
|
||||
import { requestManager } from '@/lib/requests/RequestManager.ts';
|
||||
import { defaultPromiseErrorHandler } from '@/util/defaultPromiseErrorHandler.ts';
|
||||
import { makeToast } from '@/components/util/Toast.tsx';
|
||||
import { SpinnerImage } from '@/components/util/SpinnerImage.tsx';
|
||||
import { TExtension } from '@/screens/util/Extensions.ts';
|
||||
|
||||
interface IProps {
|
||||
extension: PartialExtension;
|
||||
extension: TExtension;
|
||||
handleUpdate: () => void;
|
||||
showSourceRepo: boolean;
|
||||
}
|
||||
|
||||
@@ -168,23 +168,6 @@ export const FULL_MANGA_FIELDS = gql`
|
||||
}
|
||||
`;
|
||||
|
||||
export const FULL_EXTENSION_FIELDS = gql`
|
||||
fragment FULL_EXTENSION_FIELDS on ExtensionType {
|
||||
apkName
|
||||
repo
|
||||
hasUpdate
|
||||
iconUrl
|
||||
isInstalled
|
||||
isNsfw
|
||||
isObsolete
|
||||
lang
|
||||
name
|
||||
pkgName
|
||||
versionCode
|
||||
versionName
|
||||
}
|
||||
`;
|
||||
|
||||
export const ABOUT_WEBUI = gql`
|
||||
fragment ABOUT_WEBUI on AboutWebUI {
|
||||
channel
|
||||
|
||||
25
src/lib/graphql/fragments/ExtensionFragments.ts
Normal file
25
src/lib/graphql/fragments/ExtensionFragments.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
/*
|
||||
* 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 EXTENSION_LIST_FIELDS = gql`
|
||||
fragment EXTENSION_LIST_FIELDS on ExtensionType {
|
||||
pkgName
|
||||
name
|
||||
lang
|
||||
versionCode
|
||||
versionName
|
||||
iconUrl
|
||||
repo
|
||||
isNsfw
|
||||
isInstalled
|
||||
isObsolete
|
||||
hasUpdate
|
||||
}
|
||||
`;
|
||||
@@ -1,6 +1,6 @@
|
||||
import {FieldPolicy, FieldReadFunction, Reference, TypePolicies, TypePolicy} from '@apollo/client/cache';
|
||||
import {
|
||||
GetChaptersMangaQuery, GetDownloadStatusQueryVariables, GetExtensionQueryVariables, GetGlobalMetadataQueryVariables,
|
||||
GetChaptersMangaQuery, GetDownloadStatusQueryVariables, GetGlobalMetadataQueryVariables,
|
||||
GetMangaQueryVariables, GetSourceBrowseQueryVariables, GetUpdateStatusQueryVariables, GetWebuiUpdateStatusQueryVariables,
|
||||
} from "@/lib/graphql/generated/graphql.ts";
|
||||
import {FieldFunctionOptions} from "@apollo/client/cache/inmemory/policies";
|
||||
@@ -579,7 +579,7 @@ export type QueryFieldPolicy = {
|
||||
checkForServerUpdates?: FieldPolicy<any> | FieldReadFunction<any>,
|
||||
checkForWebUIUpdate?: FieldPolicy<any> | FieldReadFunction<any>,
|
||||
downloadStatus?: FieldPolicy<Reference, Reference, Reference, FieldFunctionOptions<GetDownloadStatusQueryVariables>> | FieldReadFunction<Reference, Reference, FieldFunctionOptions<GetDownloadStatusQueryVariables>>,
|
||||
extension?: FieldPolicy<Reference, Reference, Reference, FieldFunctionOptions<GetExtensionQueryVariables>> | FieldReadFunction<Reference, Reference, FieldFunctionOptions<GetExtensionQueryVariables>>,
|
||||
extension?: FieldPolicy<any> | FieldReadFunction<any>,
|
||||
extensions?: FieldPolicy<any> | FieldReadFunction<any>,
|
||||
getWebUIUpdateStatus?: FieldPolicy<Reference, Reference, Reference, FieldFunctionOptions<GetWebuiUpdateStatusQueryVariables>> | FieldReadFunction<Reference, Reference, FieldFunctionOptions<GetWebuiUpdateStatusQueryVariables>>,
|
||||
lastUpdateTimestamp?: FieldPolicy<any> | FieldReadFunction<any>,
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -7,64 +7,56 @@
|
||||
*/
|
||||
|
||||
import gql from 'graphql-tag';
|
||||
import { FULL_EXTENSION_FIELDS } from '@/lib/graphql/Fragments';
|
||||
import { EXTENSION_LIST_FIELDS } from '@/lib/graphql/fragments/ExtensionFragments.ts';
|
||||
|
||||
// makes the server fetch and return the latest extensions
|
||||
export const GET_EXTENSIONS_FETCH = gql`
|
||||
${FULL_EXTENSION_FIELDS}
|
||||
${EXTENSION_LIST_FIELDS}
|
||||
|
||||
mutation GET_EXTENSIONS_FETCH($input: FetchExtensionsInput = {}) {
|
||||
fetchExtensions(input: $input) {
|
||||
clientMutationId
|
||||
extensions {
|
||||
...FULL_EXTENSION_FIELDS
|
||||
...EXTENSION_LIST_FIELDS
|
||||
}
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
export const UPDATE_EXTENSION = gql`
|
||||
${EXTENSION_LIST_FIELDS}
|
||||
|
||||
mutation UPDATE_EXTENSION($input: UpdateExtensionInput!) {
|
||||
updateExtension(input: $input) {
|
||||
clientMutationId
|
||||
extension {
|
||||
pkgName
|
||||
apkName
|
||||
repo
|
||||
versionName
|
||||
versionCode
|
||||
isInstalled
|
||||
isObsolete
|
||||
hasUpdate
|
||||
...EXTENSION_LIST_FIELDS
|
||||
}
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
export const UPDATE_EXTENSIONS = gql`
|
||||
${EXTENSION_LIST_FIELDS}
|
||||
|
||||
mutation UPDATE_EXTENSIONS($input: UpdateExtensionsInput!) {
|
||||
updateExtensions(input: $input) {
|
||||
clientMutationId
|
||||
extensions {
|
||||
pkgName
|
||||
apkName
|
||||
repo
|
||||
versionName
|
||||
versionCode
|
||||
isInstalled
|
||||
isObsolete
|
||||
hasUpdate
|
||||
...EXTENSION_LIST_FIELDS
|
||||
}
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
export const INSTALL_EXTERNAL_EXTENSION = gql`
|
||||
${FULL_EXTENSION_FIELDS}
|
||||
${EXTENSION_LIST_FIELDS}
|
||||
|
||||
mutation INSTALL_EXTERNAL_EXTENSION($file: Upload!) {
|
||||
installExternalExtension(input: { extensionFile: $file }) {
|
||||
clientMutationId
|
||||
extension {
|
||||
...FULL_EXTENSION_FIELDS
|
||||
...EXTENSION_LIST_FIELDS
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,22 +7,14 @@
|
||||
*/
|
||||
|
||||
import gql from 'graphql-tag';
|
||||
import { FULL_EXTENSION_FIELDS, PAGE_INFO } from '@/lib/graphql/Fragments';
|
||||
|
||||
// returns the current extension from the database
|
||||
export const GET_EXTENSION = gql`
|
||||
${FULL_EXTENSION_FIELDS}
|
||||
query GET_EXTENSION($pkgName: String!) {
|
||||
extension(pkgName: $pkgName) {
|
||||
...FULL_EXTENSION_FIELDS
|
||||
}
|
||||
}
|
||||
`;
|
||||
import { PAGE_INFO } from '@/lib/graphql/Fragments';
|
||||
import { EXTENSION_LIST_FIELDS } from '@/lib/graphql/fragments/ExtensionFragments.ts';
|
||||
|
||||
// returns the current extensions from the database
|
||||
export const GET_EXTENSIONS = gql`
|
||||
${FULL_EXTENSION_FIELDS}
|
||||
${EXTENSION_LIST_FIELDS}
|
||||
${PAGE_INFO}
|
||||
|
||||
query GET_EXTENSIONS(
|
||||
$after: Cursor
|
||||
$before: Cursor
|
||||
@@ -46,7 +38,7 @@ export const GET_EXTENSIONS = gql`
|
||||
orderByType: $orderByType
|
||||
) {
|
||||
nodes {
|
||||
...FULL_EXTENSION_FIELDS
|
||||
...EXTENSION_LIST_FIELDS
|
||||
}
|
||||
pageInfo {
|
||||
...PAGE_INFO
|
||||
|
||||
@@ -283,7 +283,7 @@ import { DOWNLOAD_STATUS_SUBSCRIPTION } from '@/lib/graphql/subscriptions/Downlo
|
||||
import { UPDATER_SUBSCRIPTION } from '@/lib/graphql/subscriptions/UpdaterSubscription.ts';
|
||||
import { GET_SERVER_SETTINGS } from '@/lib/graphql/queries/SettingsQuery.ts';
|
||||
import { UPDATE_SERVER_SETTINGS } from '@/lib/graphql/mutations/SettingsMutation.ts';
|
||||
import { BASE_MANGA_FIELDS, FULL_EXTENSION_FIELDS, GLOBAL_METADATA } from '@/lib/graphql/Fragments.ts';
|
||||
import { BASE_MANGA_FIELDS, GLOBAL_METADATA } from '@/lib/graphql/Fragments.ts';
|
||||
import { CLEAR_SERVER_CACHE } from '@/lib/graphql/mutations/ImageMutation.ts';
|
||||
import { RESET_WEBUI_UPDATE_STATUS, UPDATE_WEBUI } from '@/lib/graphql/mutations/ServerInfoMutation.ts';
|
||||
import { WEBUI_UPDATE_SUBSCRIPTION } from '@/lib/graphql/subscriptions/ServerInfoSubscription.ts';
|
||||
@@ -303,6 +303,7 @@ import {
|
||||
import { ControlledPromise } from '@/lib/ControlledPromise.ts';
|
||||
import { MetadataMigrationSettings, TManga } from '@/typings.ts';
|
||||
import { DOWNLOAD_STATUS_FIELDS } from '@/lib/graphql/fragments/DownloadFragments.ts';
|
||||
import { EXTENSION_LIST_FIELDS } from '@/lib/graphql/fragments/ExtensionFragments.ts';
|
||||
|
||||
enum GQLMethod {
|
||||
QUERY = 'QUERY',
|
||||
@@ -1181,7 +1182,7 @@ export class RequestManager {
|
||||
>['extensions'][0]
|
||||
>({
|
||||
id: this.graphQLClient.client.cache.identify(extension),
|
||||
fragment: FULL_EXTENSION_FIELDS,
|
||||
fragment: EXTENSION_LIST_FIELDS,
|
||||
}) ?? extension,
|
||||
),
|
||||
},
|
||||
|
||||
@@ -25,6 +25,7 @@ import {
|
||||
GroupedExtensions,
|
||||
GroupedExtensionsResult,
|
||||
isExtensionStateOrLanguage,
|
||||
TExtension,
|
||||
translateExtensionLanguage,
|
||||
} from '@/screens/util/Extensions';
|
||||
import { AppbarSearch } from '@/components/util/AppbarSearch';
|
||||
@@ -32,7 +33,6 @@ import { LoadingPlaceholder } from '@/components/util/LoadingPlaceholder';
|
||||
import { makeToaster } from '@/components/util/Toast';
|
||||
import { LangSelect } from '@/components/navbar/action/LangSelect';
|
||||
import { ExtensionCard } from '@/components/ExtensionCard';
|
||||
import { PartialExtension } from '@/typings.ts';
|
||||
import { NavBarContext } from '@/components/context/NavbarContext.tsx';
|
||||
import { StyledGroupedVirtuoso } from '@/components/virtuoso/StyledGroupedVirtuoso.tsx';
|
||||
import { StyledGroupHeader } from '@/components/virtuoso/StyledGroupHeader.tsx';
|
||||
@@ -44,7 +44,7 @@ import { MediaQuery } from '@/lib/ui/MediaQuery.tsx';
|
||||
const LANGUAGE = 0;
|
||||
const EXTENSIONS = 1;
|
||||
|
||||
function getExtensionsInfo(extensions: PartialExtension[]): {
|
||||
function getExtensionsInfo(extensions: TExtension[]): {
|
||||
allLangs: string[];
|
||||
groupedExtensions: GroupedExtensionsResult;
|
||||
} {
|
||||
|
||||
@@ -7,8 +7,9 @@
|
||||
*/
|
||||
|
||||
import { t } from 'i18next';
|
||||
import { PartialExtension, TranslationKey } from '@/typings';
|
||||
import { TranslationKey } from '@/typings';
|
||||
import { DefaultLanguage, langCodeToName } from '@/util/language';
|
||||
import { ExtensionType } from '@/lib/graphql/generated/graphql.ts';
|
||||
|
||||
export enum ExtensionState {
|
||||
INSTALLED = 'INSTALLED',
|
||||
@@ -16,16 +17,31 @@ export enum ExtensionState {
|
||||
OBSOLETE = 'OBSOLETE',
|
||||
}
|
||||
|
||||
export type GroupedExtensionsResult<KEY extends string = string> = [KEY, PartialExtension[]][];
|
||||
export type TExtension = Pick<
|
||||
ExtensionType,
|
||||
| 'pkgName'
|
||||
| 'name'
|
||||
| 'lang'
|
||||
| 'versionCode'
|
||||
| 'versionName'
|
||||
| 'iconUrl'
|
||||
| 'repo'
|
||||
| 'isNsfw'
|
||||
| 'isInstalled'
|
||||
| 'isObsolete'
|
||||
| 'hasUpdate'
|
||||
>;
|
||||
|
||||
export type GroupedExtensionsResult<KEY extends string = string> = [KEY, TExtension[]][];
|
||||
|
||||
export type GroupedByExtensionState = {
|
||||
[state in ExtensionState]: PartialExtension[];
|
||||
[state in ExtensionState]: TExtension[];
|
||||
};
|
||||
|
||||
export type GroupedByLanguage = {
|
||||
[language in DefaultLanguage]: PartialExtension[];
|
||||
[language in DefaultLanguage]: TExtension[];
|
||||
} & {
|
||||
[language: string]: PartialExtension[];
|
||||
[language: string]: TExtension[];
|
||||
};
|
||||
|
||||
export type GroupedExtensions = GroupedByExtensionState & GroupedByLanguage;
|
||||
|
||||
@@ -12,7 +12,6 @@ import { ParseKeys } from 'i18next';
|
||||
import { Location } from 'react-router-dom';
|
||||
import {
|
||||
GetChaptersReaderQuery,
|
||||
GetExtensionQuery,
|
||||
GetMangaQuery,
|
||||
GetServerSettingsQuery,
|
||||
GetSourceBrowseQuery,
|
||||
@@ -32,8 +31,6 @@ declare module 'react-router-dom' {
|
||||
|
||||
export type TranslationKey = ParseKeys;
|
||||
|
||||
export type PartialExtension = GetExtensionQuery['extension'];
|
||||
|
||||
export interface IPos {
|
||||
type: 'selectState' | 'textState' | 'checkBoxState' | 'triState' | 'sortState';
|
||||
position: number;
|
||||
|
||||
@@ -41,7 +41,7 @@ const addImports = format(
|
||||
`import { FieldPolicy, FieldReadFunction, TypePolicies, TypePolicy } from '@apollo/client/cache';`,
|
||||
`import {FieldPolicy, FieldReadFunction, Reference, TypePolicies, TypePolicy} from '@apollo/client/cache';
|
||||
import {
|
||||
\tGetChaptersMangaQuery, GetDownloadStatusQueryVariables, GetExtensionQueryVariables, GetGlobalMetadataQueryVariables,
|
||||
\tGetChaptersMangaQuery, GetDownloadStatusQueryVariables, GetGlobalMetadataQueryVariables,
|
||||
\tGetMangaQueryVariables, GetSourceBrowseQueryVariables, GetUpdateStatusQueryVariables, GetWebuiUpdateStatusQueryVariables,
|
||||
} from "@/lib/graphql/generated/graphql.ts";
|
||||
import {FieldFunctionOptions} from "@apollo/client/cache/inmemory/policies";`,
|
||||
@@ -89,7 +89,7 @@ const fixTypingOfQueryTypePolicies = format(
|
||||
\tcheckForServerUpdates?: FieldPolicy<any> | FieldReadFunction<any>,
|
||||
\tcheckForWebUIUpdate?: FieldPolicy<any> | FieldReadFunction<any>,
|
||||
\tdownloadStatus?: FieldPolicy<Reference, Reference, Reference, FieldFunctionOptions<GetDownloadStatusQueryVariables>> | FieldReadFunction<Reference, Reference, FieldFunctionOptions<GetDownloadStatusQueryVariables>>,
|
||||
\textension?: FieldPolicy<Reference, Reference, Reference, FieldFunctionOptions<GetExtensionQueryVariables>> | FieldReadFunction<Reference, Reference, FieldFunctionOptions<GetExtensionQueryVariables>>,
|
||||
\textension?: FieldPolicy<any> | FieldReadFunction<any>,
|
||||
\textensions?: FieldPolicy<any> | FieldReadFunction<any>,
|
||||
\tgetWebUIUpdateStatus?: FieldPolicy<Reference, Reference, Reference, FieldFunctionOptions<GetWebuiUpdateStatusQueryVariables>> | FieldReadFunction<Reference, Reference, FieldFunctionOptions<GetWebuiUpdateStatusQueryVariables>>,
|
||||
\tlastUpdateTimestamp?: FieldPolicy<any> | FieldReadFunction<any>,
|
||||
|
||||
Reference in New Issue
Block a user