mirror of
https://github.com/zkldi/Tachi.git
synced 2026-10-10 16:28:17 +03:00
Merge pull request #726 from Bottersnike/fix/bm-import-information
This commit is contained in:
@@ -4,6 +4,7 @@ import { Sleep } from "util/misc";
|
||||
import { useState } from "react";
|
||||
import { ImportDocument, integer } from "tachi-common";
|
||||
import { ImportStates, NotStartedState } from "types/import";
|
||||
import { ImportIDReturn } from "types/api-returns";
|
||||
|
||||
export interface ImportDeferred {
|
||||
url: string;
|
||||
@@ -41,14 +42,17 @@ export default function useImport(url: string, options: RequestInit) {
|
||||
|
||||
// 200 means the import was processed on-router.
|
||||
if (initRes.statusCode === 200) {
|
||||
const importRes = await APIFetchV1<ImportDocument>(`/imports/${initRes.body.importID}`);
|
||||
const importRes = await APIFetchV1<ImportIDReturn>(`/imports/${initRes.body.importID}`);
|
||||
|
||||
if (!importRes.success) {
|
||||
setImportState({ state: "failed", error: importRes.description });
|
||||
return;
|
||||
}
|
||||
|
||||
setImportState({ state: "done", import: importRes.body as ImportDocument });
|
||||
setImportState({
|
||||
state: "done",
|
||||
import: importRes.body.import,
|
||||
});
|
||||
} else if (initRes.statusCode === 202) {
|
||||
// 202 means the import is processing. We'll have to poll the
|
||||
// status of the import in real time to see whats happening.
|
||||
@@ -63,7 +67,11 @@ export default function useImport(url: string, options: RequestInit) {
|
||||
if (pollRes.success) {
|
||||
if (pollRes.body.importStatus === "completed") {
|
||||
isImportFinished = true;
|
||||
setImportState({ state: "done", import: pollRes.body.import });
|
||||
if (importState.state === "done") {
|
||||
setImportState({ ...importState, import: pollRes.body.import });
|
||||
} else {
|
||||
setImportState({ state: "done", import: pollRes.body.import });
|
||||
}
|
||||
} else {
|
||||
setImportState({
|
||||
state: "waiting_processing",
|
||||
|
||||
@@ -23,6 +23,7 @@ import {
|
||||
UserGameStatsSnapshot,
|
||||
GoalSubscriptionDocument,
|
||||
ChallengeSubscriptionDocument,
|
||||
ImportDocument,
|
||||
} from "tachi-common";
|
||||
|
||||
export interface UGPTStatsReturn<I extends IDStrings = IDStrings> {
|
||||
@@ -191,3 +192,12 @@ export interface ChartRivalsReturn {
|
||||
rivals: Array<PublicUserDocument>;
|
||||
pbs: Array<PBScoreDocument>;
|
||||
}
|
||||
|
||||
export interface ImportIDReturn {
|
||||
scores: ScoreDocument[];
|
||||
songs: SongDocument[];
|
||||
charts: ChartDocument[];
|
||||
sessions: SessionDocument[];
|
||||
import: ImportDocument;
|
||||
user: PublicUserDocument;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user