From 6c5da883ccc681b531c922c1bfb7fbb4b221520f Mon Sep 17 00:00:00 2001 From: ci7lus <7887955+ci7lus@users.noreply.github.com> Date: Sun, 22 Oct 2023 18:06:39 +0900 Subject: [PATCH] =?UTF-8?q?fix(annict):=20=E3=83=AA=E3=82=AF=E3=82=A8?= =?UTF-8?q?=E3=82=B9=E3=83=88=E3=82=92100=E4=BD=9C=E5=93=81=E5=8C=BA?= =?UTF-8?q?=E5=88=87=E3=82=8A=E3=81=AB=E3=81=97=E3=81=A6=E3=82=BF=E3=82=A4?= =?UTF-8?q?=E3=83=A0=E3=82=A2=E3=82=A6=E3=83=88=E3=81=97=E3=81=AA=E3=81=84?= =?UTF-8?q?=E3=82=88=E3=81=86=E3=81=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- gql-documents/annict/lib.gql | 4 +-- src/annictGql.ts | 5 +-- src/components/CheckDiff.tsx | 4 +++ src/components/DiffFetchButton.tsx | 1 + src/components/DiffTable.tsx | 56 +++++++++++++++-------------- src/components/MissingWorkTable.tsx | 28 +++++++-------- 6 files changed, 54 insertions(+), 44 deletions(-) diff --git a/gql-documents/annict/lib.gql b/gql-documents/annict/lib.gql index 51ef35d..df8bc90 100644 --- a/gql-documents/annict/lib.gql +++ b/gql-documents/annict/lib.gql @@ -1,6 +1,6 @@ -query queryLibrary($states: [StatusState!], $after: String) { +query queryLibrary($states: [StatusState!], $after: String, $amount: Int) { viewer { - libraryEntries(states: $states, after: $after) { + libraryEntries(states: $states, after: $after, first: $amount) { nodes { work { id diff --git a/src/annictGql.ts b/src/annictGql.ts index aeae262..0a87701 100644 --- a/src/annictGql.ts +++ b/src/annictGql.ts @@ -1148,6 +1148,7 @@ export enum WorkOrderField { export type queryLibraryQueryVariables = Exact<{ states: InputMaybe | StatusState> after: InputMaybe + amount: InputMaybe }> export type queryLibraryQuery = { @@ -1229,9 +1230,9 @@ export type getMeQuery = { } export const queryLibraryDocument = gql` - query queryLibrary($states: [StatusState!], $after: String) { + query queryLibrary($states: [StatusState!], $after: String, $amount: Int) { viewer { - libraryEntries(states: $states, after: $after) { + libraryEntries(states: $states, after: $after, first: $amount) { nodes { work { id diff --git a/src/components/CheckDiff.tsx b/src/components/CheckDiff.tsx index c9bae38..96f1c31 100644 --- a/src/components/CheckDiff.tsx +++ b/src/components/CheckDiff.tsx @@ -66,6 +66,10 @@ export const CheckDiff = ({ ) }, [checks, idMap, ignores]) const handleReset = useCallback(() => { + const confirmed = confirm("Are you sure you want to reset?") + if (!confirmed) { + return + } setIgnores((ignores) => { setChecks((checks) => { const copiedChecks = new Set(checks) diff --git a/src/components/DiffFetchButton.tsx b/src/components/DiffFetchButton.tsx index c37ebab..885cd0e 100644 --- a/src/components/DiffFetchButton.tsx +++ b/src/components/DiffFetchButton.tsx @@ -195,6 +195,7 @@ export const DiffFetchButton: React.FC<{ const result: queryLibraryQuery = await annict.queryLibrary({ after, states: statuses, + amount: 100, }) const structedWorks = result.viewer?.libraryEntries?.nodes diff --git a/src/components/DiffTable.tsx b/src/components/DiffTable.tsx index 6b595f3..5ece818 100644 --- a/src/components/DiffTable.tsx +++ b/src/components/DiffTable.tsx @@ -1,5 +1,5 @@ import { ActionIcon, Anchor, Checkbox, Table, Text } from "@mantine/core" -import { useCallback, useMemo } from "react" +import { useCallback, useMemo, useState } from "react" import React from "react" import { Forbid } from "tabler-icons-react" import { @@ -27,9 +27,13 @@ export const DiffTable = ({ setIgnores: React.Dispatch> targetService: TargetService }) => { + const [ignoresSnapshot] = useState(ignores) const sortedMemo = useMemo( - () => diffs.sort((_, b) => (ignores.includes(b.work.annictId) ? -1 : 0)), - [diffs, ignores] + () => + diffs.sort((_, b) => + ignoresSnapshot.includes(b.work.annictId) ? -1 : 0 + ), + [diffs, ignoresSnapshot] ) const getRelationId = useCallback( (work: AnimeWork) => { @@ -43,24 +47,24 @@ export const DiffTable = ({ ) return ( - - - - - - - - - - + + + Include? + Title + Annict + {TARGET_SERVICE_NAMES[targetService]} + Ignore + + + {sortedMemo.map(({ work, target }) => ( - - - - - - - + + ))} - +
Include?TitleAnnict{TARGET_SERVICE_NAMES[targetService]}Ignore
+ { @@ -76,8 +80,8 @@ export const DiffTable = ({ }} readOnly={true} /> - + + - + + {WATCH_STATUS_MAP[work.status]} {!work.noEpisodes && ` (${work.watchedEpisodeCount})`} - + + {target ? ( `${WATCH_STATUS_MAP[target.status]} (${ @@ -120,8 +124,8 @@ export const DiffTable = ({ )} - + + { @@ -146,10 +150,10 @@ export const DiffTable = ({ > -
) } diff --git a/src/components/MissingWorkTable.tsx b/src/components/MissingWorkTable.tsx index 5b7454e..2c0e994 100644 --- a/src/components/MissingWorkTable.tsx +++ b/src/components/MissingWorkTable.tsx @@ -36,16 +36,16 @@ export const MissingWorkTable = ({ ) return ( - - - - - - - + + + Title + Status + + + {works.map((work) => ( - - - - + + ))} - +
TitleStatus
+ + )} - + + {WATCH_STATUS_MAP[work.status]} {!work.noEpisodes && ` (${work.watchedEpisodeCount})`} -
) }