diff --git a/client/src/components/util/import/useImport.ts b/client/src/components/util/import/useImport.ts index 7c11aba65..17f32b9cc 100644 --- a/client/src/components/util/import/useImport.ts +++ b/client/src/components/util/import/useImport.ts @@ -3,7 +3,8 @@ import { APIFetchV1 } from "util/api"; import { Sleep } from "util/misc"; import { useState } from "react"; import { ImportDocument, integer } from "tachi-common"; -import { ImportInformation, ImportStates, NotStartedState } from "types/import"; +import { ImportStates, NotStartedState } from "types/import"; +import { ImportIDReturn } from "types/api-returns"; export interface ImportDeferred { url: string; @@ -41,9 +42,7 @@ export default function useImport(url: string, options: RequestInit) { // 200 means the import was processed on-router. if (initRes.statusCode === 200) { - const importRes = await APIFetchV1( - `/imports/${initRes.body.importID}` - ); + const importRes = await APIFetchV1(`/imports/${initRes.body.importID}`); if (!importRes.success) { setImportState({ state: "failed", error: importRes.description }); @@ -52,8 +51,7 @@ export default function useImport(url: string, options: RequestInit) { setImportState({ state: "done", - import: (importRes.body as ImportInformation).import, - details: importRes.body as ImportInformation, + import: importRes.body.import, }); } else if (initRes.statusCode === 202) { // 202 means the import is processing. We'll have to poll the @@ -72,11 +70,7 @@ export default function useImport(url: string, options: RequestInit) { if (importState.state === "done") { setImportState({ ...importState, import: pollRes.body.import }); } else { - setImportState({ - state: "done", - import: pollRes.body.import, - details: null, - }); + setImportState({ state: "done", import: pollRes.body.import }); } } else { setImportState({ diff --git a/client/src/types/api-returns.ts b/client/src/types/api-returns.ts index 67baaa312..30636a9e1 100644 --- a/client/src/types/api-returns.ts +++ b/client/src/types/api-returns.ts @@ -23,6 +23,7 @@ import { UserGameStatsSnapshot, GoalSubscriptionDocument, ChallengeSubscriptionDocument, + ImportDocument, } from "tachi-common"; export interface UGPTStatsReturn { @@ -191,3 +192,12 @@ export interface ChartRivalsReturn { rivals: Array; pbs: Array; } + +export interface ImportIDReturn { + scores: ScoreDocument[]; + songs: SongDocument[]; + charts: ChartDocument[]; + sessions: SessionDocument[]; + import: ImportDocument; + user: PublicUserDocument; +} diff --git a/client/src/types/import.ts b/client/src/types/import.ts index aee720765..1de7d1363 100644 --- a/client/src/types/import.ts +++ b/client/src/types/import.ts @@ -1,37 +1,10 @@ -import { - ChartDocument, - ImportDocument, - PublicUserDocument, - ScoreDocument, - SessionDocument, - SongDocument, -} from "tachi-common"; - -export type ImportInformation = { - scores: ScoreDocument[]; - songs: SongDocument[]; - charts: ChartDocument[]; - sessions: SessionDocument[]; - import: ImportDocument; - user: PublicUserDocument; -}; +import { ImportDocument } from "tachi-common"; export type ImportStates = | { state: "not_started" } | { state: "waiting_init" } | { state: "waiting_processing"; progressInfo: { description: string } } - | { - state: "done"; - import: ImportDocument; - details: null | { - import: ImportDocument; - scores: ScoreDocument[]; - songs: SongDocument[]; - charts: ChartDocument[]; - sessions: SessionDocument[]; - user: PublicUserDocument; - }; - } + | { state: "done"; import: ImportDocument } | { state: "failed"; error: string }; export const NotStartedState: ImportStates = { state: "not_started" }; diff --git a/client/src/util/submit-file.ts b/client/src/util/submit-file.ts index fabb232a6..ca0f18b54 100644 --- a/client/src/util/submit-file.ts +++ b/client/src/util/submit-file.ts @@ -33,7 +33,7 @@ export default async function SubmitFile( ); if (res.success) { - setState({ state: "done", import: res.body, details: null }); + setState({ state: "done", import: res.body }); } else { setState({ state: "failed", error: res.description }); }