Skip to content

Commit

Permalink
Use gql for "about"
Browse files Browse the repository at this point in the history
  • Loading branch information
schroda committed Oct 27, 2023
1 parent 80cb06d commit 59468bc
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 14 deletions.
10 changes: 7 additions & 3 deletions src/lib/requests/RequestManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import { OperationVariables } from '@apollo/client/core';
import {
BackupValidationResult,
BatchChaptersChange,
IAbout,
ICategory,
IChapter,
IExtension,
Expand All @@ -44,13 +43,16 @@ import { HttpMethod as DefaultHttpMethod, IRestClient, RestClient } from '@/lib/
import storage from '@/util/localStorage.tsx';
import { GraphQLClient } from '@/lib/requests/client/GraphQLClient.ts';
import {
GetAboutQuery,
GetAboutQueryVariables,
GetGlobalMetadatasQuery,
GetGlobalMetadatasQueryVariables,
SetGlobalMetadataMutation,
SetGlobalMetadataMutationVariables,
} from '@/lib/graphql/generated/graphql.ts';
import { GET_GLOBAL_METADATA, GET_GLOBAL_METADATAS } from '@/lib/graphql/queries/GlobalMetadataQuery.ts';
import { SET_GLOBAL_METADATA } from '@/lib/graphql/mutations/GlobalMetadataMutation.ts';
import { GET_ABOUT } from '@/lib/graphql/queries/ServerInfoQuery.ts';

enum SWRHttpMethod {
SWR_GET,
Expand Down Expand Up @@ -445,8 +447,10 @@ export class RequestManager {
);
}

public useGetAbout(swrOptions?: SWROptions<IAbout>): AbortableSWRResponse<IAbout> {
return this.doRequest(HttpMethod.SWR_GET, 'settings/about', { swrOptions });
public useGetAbout(
options?: QueryHookOptions<GetAboutQuery, GetAboutQueryVariables>,
): AbortableApolloUseQueryResponse<GetAboutQuery, GetAboutQueryVariables> {
return this.doRequestNew(GQLMethod.USE_QUERY, GET_ABOUT, {}, options);
}

public useCheckForUpdate(swrOptions?: SWROptions<UpdateCheck[]>): AbortableSWRResponse<UpdateCheck[]> {
Expand Down
3 changes: 2 additions & 1 deletion src/screens/settings/About.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ export default function About() {
setAction(null);
}, [t]);

const { data: about } = requestManager.useGetAbout();
const { data } = requestManager.useGetAbout();
const about = data?.about;

useSetDefaultBackTo('settings');

Expand Down
10 changes: 0 additions & 10 deletions src/typings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -253,16 +253,6 @@ export interface IReaderProps {
prevChapter: () => void;
}

export interface IAbout {
name: string;
version: string;
revision: string;
buildType: 'Stable' | 'Preview';
buildTime: number;
github: string;
discord: string;
}

export interface IDownloadChapter {
chapterIndex: number;
mangaId: number;
Expand Down

0 comments on commit 59468bc

Please sign in to comment.