mirror of
https://github.com/zkldi/Tachi.git
synced 2026-10-10 08:18:12 +03:00
More big updates (just incase hdd dies or something)
This commit is contained in:
@@ -45,6 +45,12 @@ export async function APIFetchV1<T = unknown>(
|
||||
|
||||
const rj = await res.json();
|
||||
|
||||
if (!rj.success) {
|
||||
console.error(rj);
|
||||
} else {
|
||||
console.log(rj.description);
|
||||
}
|
||||
|
||||
if (!rj.success && displayFailure) {
|
||||
toast.error(rj.description, { duration: 10_000 });
|
||||
}
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
export const ONE_SECOND = 1000;
|
||||
export const ONE_MINUTE = ONE_SECOND * 60;
|
||||
export const ONE_HOUR = ONE_MINUTE * 60;
|
||||
export const ONE_DAY = ONE_HOUR * 24;
|
||||
export const ONE_WEEK = ONE_DAY * 7;
|
||||
@@ -0,0 +1,32 @@
|
||||
import {
|
||||
ChartDocument,
|
||||
Game,
|
||||
IDStrings,
|
||||
integer,
|
||||
SessionScoreInfo,
|
||||
SongDocument,
|
||||
} from "tachi-common";
|
||||
|
||||
export function GetPBs(scoreInfo: SessionScoreInfo[]) {
|
||||
return scoreInfo.map(e => e.isNewScore === true || e.lampDelta > 0 || e.scoreDelta > 0);
|
||||
}
|
||||
|
||||
export function CreateSongMap<G extends Game = Game>(songs: SongDocument<G>[]) {
|
||||
const songMap = new Map<integer, SongDocument<G>>();
|
||||
|
||||
for (const song of songs) {
|
||||
songMap.set(song.id, song);
|
||||
}
|
||||
|
||||
return songMap;
|
||||
}
|
||||
|
||||
export function CreateChartMap<I extends IDStrings = IDStrings>(charts: ChartDocument<I>[]) {
|
||||
const chartMap = new Map<string, ChartDocument<I>>();
|
||||
|
||||
for (const chart of charts) {
|
||||
chartMap.set(chart.chartID, chart);
|
||||
}
|
||||
|
||||
return chartMap;
|
||||
}
|
||||
Reference in New Issue
Block a user