Implement tracker login and logout
This commit is contained in:
@@ -2904,6 +2904,27 @@ export type UpdateSourcePreferencesMutationVariables = Exact<{
|
||||
|
||||
export type UpdateSourcePreferencesMutation = { __typename?: 'Mutation', updateSourcePreference: { __typename?: 'UpdateSourcePreferencePayload', clientMutationId?: string | null, source: { __typename?: 'SourceType', id: any, preferences: Array<{ __typename?: 'CheckBoxPreference', summary?: string | null, key: string, type: 'CheckBoxPreference', CheckBoxCheckBoxCurrentValue?: boolean | null, CheckBoxDefault: boolean, CheckBoxTitle: string } | { __typename?: 'EditTextPreference', text?: string | null, summary?: string | null, key: string, dialogTitle?: string | null, dialogMessage?: string | null, type: 'EditTextPreference', EditTextPreferenceCurrentValue?: string | null, EditTextPreferenceDefault?: string | null, EditTextPreferenceTitle?: string | null } | { __typename?: 'ListPreference', summary?: string | null, key: string, entryValues: Array<string>, entries: Array<string>, type: 'ListPreference', ListPreferenceCurrentValue?: string | null, ListPreferenceDefault?: string | null, ListPreferenceTitle?: string | null } | { __typename?: 'MultiSelectListPreference', dialogMessage?: string | null, dialogTitle?: string | null, summary?: string | null, key: string, entryValues: Array<string>, entries: Array<string>, type: 'MultiSelectListPreference', MultiSelectListPreferenceTitle?: string | null, MultiSelectListPreferenceDefault?: Array<string> | null, MultiSelectListPreferenceCurrentValue?: Array<string> | null } | { __typename?: 'SwitchPreference', summary?: string | null, key: string, type: 'SwitchPreference', SwitchPreferenceCurrentValue?: boolean | null, SwitchPreferenceDefault: boolean, SwitchPreferenceTitle: string }> } } };
|
||||
|
||||
export type TrackerLoginOauthMutationVariables = Exact<{
|
||||
input: LoginTrackerOAuthInput;
|
||||
}>;
|
||||
|
||||
|
||||
export type TrackerLoginOauthMutation = { __typename?: 'Mutation', loginTrackerOAuth: { __typename?: 'LoginTrackerOAuthPayload', tracker: { __typename?: 'TrackerType', id: number, isLoggedIn: boolean, authUrl?: string | null } } };
|
||||
|
||||
export type TrackerLoginCredentialsMutationVariables = Exact<{
|
||||
input: LoginTrackerCredentialsInput;
|
||||
}>;
|
||||
|
||||
|
||||
export type TrackerLoginCredentialsMutation = { __typename?: 'Mutation', loginTrackerCredentials: { __typename?: 'LoginTrackerCredentialsPayload', isLoggedIn: boolean, tracker: { __typename?: 'TrackerType', id: number, isLoggedIn: boolean, authUrl?: string | null } } };
|
||||
|
||||
export type TrackerLogoutMutationVariables = Exact<{
|
||||
trackerId: Scalars['Int']['input'];
|
||||
}>;
|
||||
|
||||
|
||||
export type TrackerLogoutMutation = { __typename?: 'Mutation', logoutTracker: { __typename?: 'LogoutTrackerPayload', clientMutationId?: string | null, tracker: { __typename?: 'TrackerType', id: number, isLoggedIn: boolean, authUrl?: string | null } } };
|
||||
|
||||
export type UpdateCategoryMangasMutationVariables = Exact<{
|
||||
input: UpdateCategoryMangaInput;
|
||||
}>;
|
||||
@@ -3129,6 +3150,11 @@ export type GetMigratableSourcesQueryVariables = Exact<{ [key: string]: never; }
|
||||
|
||||
export type GetMigratableSourcesQuery = { __typename?: 'Query', mangas: { __typename?: 'MangaNodeList', nodes: Array<{ __typename?: 'MangaType', sourceId: any, source?: { __typename?: 'SourceType', id: any, name: string, lang: string, iconUrl: string } | null }> } };
|
||||
|
||||
export type GetTrackersQueryVariables = Exact<{ [key: string]: never; }>;
|
||||
|
||||
|
||||
export type GetTrackersQuery = { __typename?: 'Query', trackers: { __typename?: 'TrackerNodeList', totalCount: number, pageInfo: { __typename?: 'PageInfo', endCursor?: any | null, hasNextPage: boolean, hasPreviousPage: boolean, startCursor?: any | null }, nodes: Array<{ __typename?: 'TrackerType', id: number, name: string, authUrl?: string | null, icon: string, isLoggedIn: boolean }> } };
|
||||
|
||||
export type GetUpdateStatusQueryVariables = Exact<{ [key: string]: never; }>;
|
||||
|
||||
|
||||
|
||||
47
src/lib/graphql/mutations/TrackerMutation.ts
Normal file
47
src/lib/graphql/mutations/TrackerMutation.ts
Normal file
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
* 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 TRACKER_LOGIN_OAUTH = gql`
|
||||
mutation TRACKER_LOGIN_OAUTH($input: LoginTrackerOAuthInput!) {
|
||||
loginTrackerOAuth(input: $input) {
|
||||
tracker {
|
||||
id
|
||||
isLoggedIn
|
||||
authUrl
|
||||
}
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
export const TRACKER_LOGIN_CREDENTIALS = gql`
|
||||
mutation TRACKER_LOGIN_CREDENTIALS($input: LoginTrackerCredentialsInput!) {
|
||||
loginTrackerCredentials(input: $input) {
|
||||
isLoggedIn
|
||||
tracker {
|
||||
id
|
||||
isLoggedIn
|
||||
authUrl
|
||||
}
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
export const TRACKER_LOGOUT = gql`
|
||||
mutation TRACKER_LOGOUT($trackerId: Int!) {
|
||||
logoutTracker(input: { trackerId: $trackerId }) {
|
||||
clientMutationId
|
||||
tracker {
|
||||
id
|
||||
isLoggedIn
|
||||
authUrl
|
||||
}
|
||||
}
|
||||
}
|
||||
`;
|
||||
29
src/lib/graphql/queries/TrackerQuery.ts
Normal file
29
src/lib/graphql/queries/TrackerQuery.ts
Normal file
@@ -0,0 +1,29 @@
|
||||
/*
|
||||
* 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';
|
||||
import { PAGE_INFO } from '@/lib/graphql/Fragments.ts';
|
||||
|
||||
export const GET_TRACKERS = gql`
|
||||
${PAGE_INFO}
|
||||
query GET_TRACKERS {
|
||||
trackers {
|
||||
totalCount
|
||||
pageInfo {
|
||||
...PAGE_INFO
|
||||
}
|
||||
nodes {
|
||||
id
|
||||
name
|
||||
authUrl
|
||||
icon
|
||||
isLoggedIn
|
||||
}
|
||||
}
|
||||
}
|
||||
`;
|
||||
@@ -177,6 +177,14 @@ import {
|
||||
GetMangaToMigrateQueryVariables,
|
||||
GetMangaToMigrateToFetchMutation,
|
||||
GetMangaToMigrateToFetchMutationVariables,
|
||||
GetTrackersQuery,
|
||||
GetTrackersQueryVariables,
|
||||
TrackerLogoutMutation,
|
||||
TrackerLogoutMutationVariables,
|
||||
TrackerLoginOauthMutation,
|
||||
TrackerLoginOauthMutationVariables,
|
||||
TrackerLoginCredentialsMutation,
|
||||
TrackerLoginCredentialsMutationVariables,
|
||||
} from '@/lib/graphql/generated/graphql.ts';
|
||||
import { GET_GLOBAL_METADATAS } from '@/lib/graphql/queries/GlobalMetadataQuery.ts';
|
||||
import { SET_GLOBAL_METADATA } from '@/lib/graphql/mutations/GlobalMetadataMutation.ts';
|
||||
@@ -257,6 +265,12 @@ import { WEBUI_UPDATE_SUBSCRIPTION } from '@/lib/graphql/subscriptions/ServerInf
|
||||
import { GET_DOWNLOAD_STATUS } from '@/lib/graphql/queries/DownloaderQuery.ts';
|
||||
import { defaultPromiseErrorHandler } from '@/util/defaultPromiseErrorHandler.ts';
|
||||
import { Queue, QueuePriority } from '@/lib/Queue.ts';
|
||||
import { GET_TRACKERS } from '@/lib/graphql/queries/TrackerQuery.ts';
|
||||
import {
|
||||
TRACKER_LOGIN_CREDENTIALS,
|
||||
TRACKER_LOGIN_OAUTH,
|
||||
TRACKER_LOGOUT,
|
||||
} from '@/lib/graphql/mutations/TrackerMutation.ts';
|
||||
|
||||
enum GQLMethod {
|
||||
QUERY = 'QUERY',
|
||||
@@ -2359,6 +2373,30 @@ export class RequestManager {
|
||||
): AbortableApolloUseQueryResponse<GetMigratableSourcesQuery, GetMigratableSourcesQueryVariables> {
|
||||
return this.doRequest(GQLMethod.USE_QUERY, GET_MIGRATABLE_SOURCES, undefined, options);
|
||||
}
|
||||
|
||||
public useGetTrackerList(
|
||||
options?: QueryHookOptions<GetTrackersQuery, GetTrackersQueryVariables>,
|
||||
): AbortableApolloUseQueryResponse<GetTrackersQuery, GetTrackersQueryVariables> {
|
||||
return this.doRequest(GQLMethod.USE_QUERY, GET_TRACKERS, undefined, options);
|
||||
}
|
||||
|
||||
public useLogoutFromTracker(
|
||||
options?: MutationHookOptions<TrackerLogoutMutation, TrackerLogoutMutationVariables>,
|
||||
): AbortableApolloUseMutationResponse<TrackerLogoutMutation, TrackerLogoutMutationVariables> {
|
||||
return this.doRequest(GQLMethod.USE_MUTATION, TRACKER_LOGOUT, undefined, options);
|
||||
}
|
||||
|
||||
public useLoginToTrackerOauth(
|
||||
options?: MutationHookOptions<TrackerLoginOauthMutation, TrackerLoginOauthMutationVariables>,
|
||||
): AbortableApolloUseMutationResponse<TrackerLoginOauthMutation, TrackerLoginOauthMutationVariables> {
|
||||
return this.doRequest(GQLMethod.USE_MUTATION, TRACKER_LOGIN_OAUTH, undefined, options);
|
||||
}
|
||||
|
||||
public useLoginToTrackerCredentials(
|
||||
options?: MutationHookOptions<TrackerLoginCredentialsMutation, TrackerLoginCredentialsMutationVariables>,
|
||||
): AbortableApolloUseMutationResponse<TrackerLoginCredentialsMutation, TrackerLoginCredentialsMutationVariables> {
|
||||
return this.doRequest(GQLMethod.USE_MUTATION, TRACKER_LOGIN_CREDENTIALS, undefined, options);
|
||||
}
|
||||
}
|
||||
|
||||
export const requestManager = new RequestManager();
|
||||
|
||||
Reference in New Issue
Block a user