mirror of
https://github.com/zkldi/Tachi.git
synced 2026-10-04 04:48:15 +03:00
refactor: rename PublicUserDocument to UserDocument
This commit is contained in:
@@ -10,7 +10,7 @@ import { HandleGoalAchievedV1 } from "../webhookHandlers/goalAchieved";
|
||||
import express from "express";
|
||||
import path from "path";
|
||||
import type { Express } from "express";
|
||||
import type { APITokenDocument, PublicUserDocument, WebhookEvents } from "tachi-common";
|
||||
import type { APITokenDocument, UserDocument, WebhookEvents } from "tachi-common";
|
||||
|
||||
export const app: Express = express();
|
||||
|
||||
@@ -85,7 +85,7 @@ app.get("/oauth/callback", async (req, res) => {
|
||||
const discordID = req.query.context;
|
||||
const apiToken = tokenRes.body.token!;
|
||||
|
||||
const whoamiRes = await TachiServerV1Get<PublicUserDocument>("/users/me", apiToken);
|
||||
const whoamiRes = await TachiServerV1Get<UserDocument>("/users/me", apiToken);
|
||||
|
||||
if (!whoamiRes.success) {
|
||||
logger.severe("Failed to request user with token we just got?", { discordID });
|
||||
|
||||
@@ -14,7 +14,7 @@ import type {
|
||||
integer,
|
||||
PBScoreDocument,
|
||||
Playtype,
|
||||
PublicUserDocument,
|
||||
UserDocument,
|
||||
SessionDocument,
|
||||
SongDocument,
|
||||
} from "tachi-common";
|
||||
@@ -22,7 +22,7 @@ import type {
|
||||
const logger = CreateLayeredLogger(LoggerLayers.apiRequests);
|
||||
|
||||
export async function GetUserInfo(userID: integer | string) {
|
||||
const res = await TachiServerV1Get<PublicUserDocument>(`/users/${userID}`, null);
|
||||
const res = await TachiServerV1Get<UserDocument>(`/users/${userID}`, null);
|
||||
|
||||
if (!res.success) {
|
||||
throw new Error(`Failed to fetch user with userID ${userID}.`);
|
||||
|
||||
@@ -4,7 +4,7 @@ import { GetGamePTConfig } from "tachi-common";
|
||||
import type { DiscordUserMapDocument } from "../database/documents";
|
||||
import type { Emittable } from "../slashCommands/types";
|
||||
import type { CommandInteraction } from "discord.js";
|
||||
import type { Difficulties, Game, IDStrings, Playtype, PublicUserDocument } from "tachi-common";
|
||||
import type { Difficulties, Game, IDStrings, Playtype, UserDocument } from "tachi-common";
|
||||
|
||||
/**
|
||||
* Utility parser for getting the game, playtype and requesting user, since this is
|
||||
@@ -15,7 +15,7 @@ export async function GetGPTAndUser(
|
||||
requestingUser: DiscordUserMapDocument
|
||||
): Promise<
|
||||
| { error: Emittable }
|
||||
| { error: null; content: { userDoc: PublicUserDocument; game: Game; playtype: Playtype } }
|
||||
| { error: null; content: { userDoc: UserDocument; game: Game; playtype: Playtype } }
|
||||
> {
|
||||
const userID = interaction.options.getString("other_user") ?? requestingUser.userID.toString();
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@ import type {
|
||||
integer,
|
||||
PBScoreDocument,
|
||||
Playtype,
|
||||
PublicUserDocument,
|
||||
UserDocument,
|
||||
ScoreDocument,
|
||||
SessionDocument,
|
||||
SongDocument,
|
||||
@@ -60,7 +60,7 @@ export function CreateImportEmbed(importDoc: ImportDocument) {
|
||||
);
|
||||
}
|
||||
|
||||
export function CreateUserEmbed(userDoc: PublicUserDocument) {
|
||||
export function CreateUserEmbed(userDoc: UserDocument) {
|
||||
return CreateEmbed()
|
||||
.setTitle(`${userDoc.username} (ID: ${userDoc.id})`)
|
||||
.setThumbnail(PrependTachiUrl(`/users/${userDoc.id}/pfp`))
|
||||
@@ -69,7 +69,7 @@ export function CreateUserEmbed(userDoc: PublicUserDocument) {
|
||||
.setURL(`${BotConfig.TACHI_SERVER_LOCATION}/dashboard/users/${userDoc.username}`);
|
||||
}
|
||||
|
||||
export function CreateGameProfileEmbed(userDoc: PublicUserDocument, ugptStats: UGPTStats) {
|
||||
export function CreateGameProfileEmbed(userDoc: UserDocument, ugptStats: UGPTStats) {
|
||||
const { game, playtype } = ugptStats.gameStats;
|
||||
|
||||
const gptConfig = GetGamePTConfig(game, playtype);
|
||||
@@ -126,7 +126,7 @@ export function CreateGameProfileEmbed(userDoc: PublicUserDocument, ugptStats: U
|
||||
}
|
||||
|
||||
export async function CreateChartScoresEmbed(
|
||||
userDoc: PublicUserDocument,
|
||||
userDoc: UserDocument,
|
||||
game: Game,
|
||||
playtype: Playtype,
|
||||
chartID: string,
|
||||
|
||||
@@ -14,7 +14,7 @@ import type {
|
||||
PBScoreDocument,
|
||||
Playtype,
|
||||
Playtypes,
|
||||
PublicUserDocument,
|
||||
UserDocument,
|
||||
ScoreCalculatedDataLookup,
|
||||
ScoreDocument,
|
||||
SongDocument,
|
||||
@@ -366,8 +366,8 @@ export function CreateSongMap<G extends Game = Game>(songs: Array<SongDocument<G
|
||||
return songMap;
|
||||
}
|
||||
|
||||
export function CreateUserMap(users: Array<PublicUserDocument>) {
|
||||
const userMap = new Map<integer, PublicUserDocument>();
|
||||
export function CreateUserMap(users: Array<UserDocument>) {
|
||||
const userMap = new Map<integer, UserDocument>();
|
||||
|
||||
for (const user of users) {
|
||||
userMap.set(user.id, user);
|
||||
|
||||
@@ -10,7 +10,7 @@ import type {
|
||||
ImportTypes,
|
||||
integer,
|
||||
Lamps,
|
||||
PublicUserDocument,
|
||||
UserDocument,
|
||||
ScoreDocument,
|
||||
SessionDocument,
|
||||
SongDocument,
|
||||
@@ -83,5 +83,5 @@ export interface SessionInfo {
|
||||
songs: Array<SongDocument>;
|
||||
charts: Array<ChartDocument>;
|
||||
scores: Array<ScoreDocument>;
|
||||
user: PublicUserDocument;
|
||||
user: UserDocument;
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ import { Button, Col, Form } from "react-bootstrap";
|
||||
import ReCAPTCHA from "react-google-recaptcha";
|
||||
import toast from "react-hot-toast";
|
||||
import { Link, useHistory } from "react-router-dom";
|
||||
import { PublicUserDocument } from "tachi-common";
|
||||
import { UserDocument } from "tachi-common";
|
||||
|
||||
export default function LoginPage() {
|
||||
useSetSubheader("Login");
|
||||
@@ -51,7 +51,7 @@ export default function LoginPage() {
|
||||
return;
|
||||
}
|
||||
|
||||
const userRJ = await APIFetchV1<PublicUserDocument>("/users/me");
|
||||
const userRJ = await APIFetchV1<UserDocument>("/users/me");
|
||||
|
||||
if (userRJ.statusCode === 403) {
|
||||
setErr("You are banned.");
|
||||
|
||||
@@ -11,7 +11,7 @@ import { Alert, Button, Col, Form } from "react-bootstrap";
|
||||
import ReCAPTCHA from "react-google-recaptcha";
|
||||
import toast from "react-hot-toast";
|
||||
import { Link, useHistory } from "react-router-dom";
|
||||
import { PublicUserDocument } from "tachi-common";
|
||||
import { UserDocument } from "tachi-common";
|
||||
import { UseFormik } from "types/react";
|
||||
|
||||
// seconds it takes for a user to actually read the rules.
|
||||
@@ -51,7 +51,7 @@ export default function RegisterPage() {
|
||||
return;
|
||||
}
|
||||
|
||||
const rj = await APIFetchV1<PublicUserDocument>(
|
||||
const rj = await APIFetchV1<UserDocument>(
|
||||
"/auth/register",
|
||||
{
|
||||
method: "POST",
|
||||
|
||||
@@ -20,7 +20,7 @@ import { ColourConfig, TachiConfig } from "lib/config";
|
||||
import React, { useContext } from "react";
|
||||
import { Alert } from "react-bootstrap";
|
||||
import { Link } from "react-router-dom";
|
||||
import { COLOUR_SET, GetGameConfig, PublicUserDocument } from "tachi-common";
|
||||
import { COLOUR_SET, GetGameConfig, UserDocument } from "tachi-common";
|
||||
import { UGSWithRankingData, UserRecentSummary } from "types/api-returns";
|
||||
import { FolderInfoComponent } from "./users/games/_game/_playtype/folders/FolderSelectPage";
|
||||
import { GameStatContainer } from "./users/UserGamesPage";
|
||||
@@ -48,7 +48,7 @@ export function DashboardPage() {
|
||||
);
|
||||
}
|
||||
|
||||
function DashboardLoggedIn({ user }: { user: PublicUserDocument }) {
|
||||
function DashboardLoggedIn({ user }: { user: UserDocument }) {
|
||||
return (
|
||||
<div>
|
||||
<span className="display-4">
|
||||
@@ -64,7 +64,7 @@ function DashboardLoggedIn({ user }: { user: PublicUserDocument }) {
|
||||
);
|
||||
}
|
||||
|
||||
function RecentInfo({ user }: { user: PublicUserDocument }) {
|
||||
function RecentInfo({ user }: { user: UserDocument }) {
|
||||
const { data, error } = useApiQuery<UserRecentSummary>(`/users/${user.id}/recent-summary`);
|
||||
|
||||
if (error) {
|
||||
@@ -172,7 +172,7 @@ function RecentInfo({ user }: { user: PublicUserDocument }) {
|
||||
);
|
||||
}
|
||||
|
||||
function UserGameStatsInfo({ user }: { user: PublicUserDocument }) {
|
||||
function UserGameStatsInfo({ user }: { user: UserDocument }) {
|
||||
return (
|
||||
<div className="row">
|
||||
<AsyncLoader
|
||||
@@ -261,7 +261,7 @@ function FeatureContainer({ tagline, description }: { tagline: string; descripti
|
||||
);
|
||||
}
|
||||
|
||||
function DashboardLoggedInNoScores({ user }: { user: PublicUserDocument }) {
|
||||
function DashboardLoggedInNoScores({ user }: { user: UserDocument }) {
|
||||
return (
|
||||
<div>
|
||||
<span className="display-4">
|
||||
|
||||
@@ -26,7 +26,7 @@ import {
|
||||
GetGamePTConfig,
|
||||
integer,
|
||||
PBScoreDocument,
|
||||
PublicUserDocument,
|
||||
UserDocument,
|
||||
SongDocument,
|
||||
} from "tachi-common";
|
||||
import {
|
||||
@@ -223,8 +223,8 @@ function ChartLeaderboardTable({
|
||||
song,
|
||||
}: {
|
||||
data: ChartPBData;
|
||||
user: PublicUserDocument | null;
|
||||
userMap: Map<integer, PublicUserDocument>;
|
||||
user: UserDocument | null;
|
||||
userMap: Map<integer, UserDocument>;
|
||||
mode: "leaderboard" | "adjacent" | "rivals";
|
||||
chart: ChartDocument;
|
||||
song: SongDocument;
|
||||
@@ -282,8 +282,8 @@ function TopShowcase({
|
||||
userMap,
|
||||
}: {
|
||||
data: ChartPBData;
|
||||
user: PublicUserDocument | null;
|
||||
userMap: Map<integer, PublicUserDocument>;
|
||||
user: UserDocument | null;
|
||||
userMap: Map<integer, UserDocument>;
|
||||
}) {
|
||||
// We have a couple of conditions.
|
||||
// User is #1: col-12 #1,
|
||||
@@ -337,7 +337,7 @@ function PlayCard({
|
||||
name,
|
||||
}: {
|
||||
pb: PBScoreDocument;
|
||||
user: PublicUserDocument;
|
||||
user: UserDocument;
|
||||
name: string;
|
||||
}) {
|
||||
return (
|
||||
|
||||
@@ -30,7 +30,7 @@ import {
|
||||
GetGamePTConfig,
|
||||
GoalDocument,
|
||||
integer,
|
||||
PublicUserDocument,
|
||||
UserDocument,
|
||||
ScoreDocument,
|
||||
SongDocument,
|
||||
GoalSubscriptionDocument,
|
||||
@@ -75,7 +75,7 @@ export default function GPTMainPage({ game, playtype }: GamePT) {
|
||||
|
||||
function RecentAchievedGoalsComponent({ game, playtype }: GamePT) {
|
||||
const { data, error } = useApiQuery<{
|
||||
users: PublicUserDocument[];
|
||||
users: UserDocument[];
|
||||
goals: GoalDocument[];
|
||||
goalSubs: GoalSubscriptionDocument[];
|
||||
}>(`/games/${game}/${playtype}/goals/recently-achieved`);
|
||||
@@ -131,7 +131,7 @@ function RecentAchievedGoalsComponent({ game, playtype }: GamePT) {
|
||||
function RecentHighlightedScoresComponent({ game, playtype }: GamePT) {
|
||||
const { data, error } = useApiQuery<{
|
||||
scores: ScoreDocument[];
|
||||
users: PublicUserDocument[];
|
||||
users: UserDocument[];
|
||||
charts: ChartDocument[];
|
||||
songs: SongDocument[];
|
||||
}>(`/games/${game}/${playtype}/scores/highlighted`);
|
||||
@@ -194,7 +194,7 @@ function RecentClassesComponent({ game, playtype }: GamePT) {
|
||||
// return <div className="text-center">Looks like nobodies got anything here... yet!</div>;
|
||||
// }
|
||||
|
||||
const userMap = new Map<integer, PublicUserDocument>();
|
||||
const userMap = new Map<integer, UserDocument>();
|
||||
|
||||
for (const user of data.users) {
|
||||
userMap.set(user.id, user);
|
||||
@@ -220,7 +220,7 @@ function AchievedClassRow({
|
||||
user,
|
||||
}: {
|
||||
classInfo: ClassAchievementDocument;
|
||||
user: PublicUserDocument;
|
||||
user: UserDocument;
|
||||
}) {
|
||||
const game = classInfo.game;
|
||||
const playtype = classInfo.playtype;
|
||||
|
||||
@@ -18,7 +18,7 @@ import {
|
||||
GetGameConfig,
|
||||
ImportTypes,
|
||||
integer,
|
||||
PublicUserDocument,
|
||||
UserDocument,
|
||||
} from "tachi-common";
|
||||
|
||||
export default function ImportPage() {
|
||||
@@ -71,7 +71,7 @@ function ShowRecentImports() {
|
||||
return <InnerShowRecentImports user={user} />;
|
||||
}
|
||||
|
||||
function InnerShowRecentImports({ user }: { user: PublicUserDocument }) {
|
||||
function InnerShowRecentImports({ user }: { user: UserDocument }) {
|
||||
const { data, error } = useApiQuery<{ importType: ImportTypes; count: integer }[]>(
|
||||
`/users/${user.id}/recent-imports`
|
||||
);
|
||||
|
||||
@@ -7,10 +7,10 @@ import useApiQuery from "components/util/query/useApiQuery";
|
||||
import React, { useEffect, useState } from "react";
|
||||
import { Button, Col, Form } from "react-bootstrap";
|
||||
import { Link } from "react-router-dom";
|
||||
import { ARCSavedProfileDocument, PublicUserDocument } from "tachi-common";
|
||||
import { ARCSavedProfileDocument, UserDocument } from "tachi-common";
|
||||
import { SetState } from "types/react";
|
||||
|
||||
export default function ARCIntegrationPage({ reqUser }: { reqUser: PublicUserDocument }) {
|
||||
export default function ARCIntegrationPage({ reqUser }: { reqUser: UserDocument }) {
|
||||
const [iidxID, setIIDXID] = useState("");
|
||||
const [sdvxID, setSDVXID] = useState("");
|
||||
|
||||
|
||||
@@ -6,9 +6,9 @@ import useApiQuery from "components/util/query/useApiQuery";
|
||||
import React, { useState } from "react";
|
||||
import { Button, Col, Form } from "react-bootstrap";
|
||||
import { Link } from "react-router-dom";
|
||||
import { FervidexSettingsDocument, PublicUserDocument } from "tachi-common";
|
||||
import { FervidexSettingsDocument, UserDocument } from "tachi-common";
|
||||
|
||||
export default function FervidexIntegrationPage({ reqUser }: { reqUser: PublicUserDocument }) {
|
||||
export default function FervidexIntegrationPage({ reqUser }: { reqUser: UserDocument }) {
|
||||
const { data: settings, error } = useApiQuery<FervidexSettingsDocument | null>(
|
||||
`/users/${reqUser.id}/integrations/fervidex/settings`
|
||||
);
|
||||
@@ -47,7 +47,7 @@ function FervidexForm({
|
||||
reqUser,
|
||||
settings,
|
||||
}: {
|
||||
reqUser: PublicUserDocument;
|
||||
reqUser: UserDocument;
|
||||
settings: FervidexSettingsDocument | null;
|
||||
}) {
|
||||
const [formSettings, setFormSettings] = useState<Omit<FervidexSettingsDocument, "userID">>(
|
||||
|
||||
@@ -6,9 +6,9 @@ import useApiQuery from "components/util/query/useApiQuery";
|
||||
import React, { useState } from "react";
|
||||
import { Button, Col, Form } from "react-bootstrap";
|
||||
import { Link } from "react-router-dom";
|
||||
import { FervidexSettingsDocument, KsHookSettingsDocument, PublicUserDocument } from "tachi-common";
|
||||
import { FervidexSettingsDocument, KsHookSettingsDocument, UserDocument } from "tachi-common";
|
||||
|
||||
export default function KsHookSV6CIntegrationPage({ reqUser }: { reqUser: PublicUserDocument }) {
|
||||
export default function KsHookSV6CIntegrationPage({ reqUser }: { reqUser: UserDocument }) {
|
||||
const { data: settings, error } = useApiQuery<FervidexSettingsDocument | null>(
|
||||
`/users/${reqUser.id}/integrations/kshook-sv6c/settings`
|
||||
);
|
||||
@@ -47,7 +47,7 @@ function KsHookSV6CForm({
|
||||
reqUser,
|
||||
settings,
|
||||
}: {
|
||||
reqUser: PublicUserDocument;
|
||||
reqUser: UserDocument;
|
||||
settings: KsHookSettingsDocument | null;
|
||||
}) {
|
||||
const [formSettings, setFormSettings] = useState<Omit<KsHookSettingsDocument, "userID">>(
|
||||
|
||||
@@ -7,9 +7,9 @@ import ApiError from "components/util/ApiError";
|
||||
import Loading from "components/util/Loading";
|
||||
import useApiQuery from "components/util/query/useApiQuery";
|
||||
import { UserContext } from "context/UserContext";
|
||||
import React, { useContext, useMemo } from "react";
|
||||
import React, { useContext, useEffect, useMemo } from "react";
|
||||
import { Button, Col, Row } from "react-bootstrap";
|
||||
import { NotificationDocument, PublicUserDocument } from "tachi-common";
|
||||
import { NotificationDocument, UserDocument } from "tachi-common";
|
||||
|
||||
export default function NotificationsPage() {
|
||||
const { user } = useContext(UserContext);
|
||||
@@ -23,7 +23,7 @@ export default function NotificationsPage() {
|
||||
return <NotificationsInnerPage user={user} />;
|
||||
}
|
||||
|
||||
function NotificationsInnerPage({ user }: { user: PublicUserDocument }) {
|
||||
function NotificationsInnerPage({ user }: { user: UserDocument }) {
|
||||
const { data, error } = useApiQuery<Array<NotificationDocument>>(
|
||||
`/users/${user.id}/notifications`
|
||||
);
|
||||
|
||||
@@ -9,11 +9,11 @@ import LinkButton from "components/util/LinkButton";
|
||||
import Muted from "components/util/Muted";
|
||||
import ReferToUser from "components/util/ReferToUser";
|
||||
import React from "react";
|
||||
import { FormatGame, PublicUserDocument, UserGameStats } from "tachi-common";
|
||||
import { FormatGame, UserDocument, UserGameStats } from "tachi-common";
|
||||
import { UGSWithRankingData } from "types/api-returns";
|
||||
|
||||
interface Props {
|
||||
reqUser: PublicUserDocument;
|
||||
reqUser: UserDocument;
|
||||
}
|
||||
|
||||
export default function UserGamesPage({ reqUser }: Props) {
|
||||
@@ -54,7 +54,7 @@ export default function UserGamesPage({ reqUser }: Props) {
|
||||
);
|
||||
}
|
||||
|
||||
function GamesInfo({ ugs, reqUser }: { ugs: UserGameStats[]; reqUser: PublicUserDocument }) {
|
||||
function GamesInfo({ ugs, reqUser }: { ugs: UserGameStats[]; reqUser: UserDocument }) {
|
||||
const gpts = GetSortedGPTs();
|
||||
|
||||
const ugsMap = new Map();
|
||||
|
||||
@@ -9,10 +9,10 @@ import useApiQuery from "components/util/query/useApiQuery";
|
||||
import SelectLinkButton from "components/util/SelectLinkButton";
|
||||
import React, { useMemo, useState } from "react";
|
||||
import { Route, Switch } from "react-router-dom";
|
||||
import { ImportDocument, ImportTrackerFailed, PublicUserDocument } from "tachi-common";
|
||||
import { ImportDocument, ImportTrackerFailed, UserDocument } from "tachi-common";
|
||||
import { FailedImportDataset, ImportDataset } from "types/tables";
|
||||
|
||||
export default function UserImportsPage({ reqUser }: { reqUser: PublicUserDocument }) {
|
||||
export default function UserImportsPage({ reqUser }: { reqUser: UserDocument }) {
|
||||
useSetSubheader(
|
||||
["Users", reqUser.username, "Imports"],
|
||||
[reqUser],
|
||||
@@ -69,7 +69,7 @@ function ViewRecentImports({
|
||||
reqUser,
|
||||
}: {
|
||||
params: URLSearchParams;
|
||||
reqUser: PublicUserDocument;
|
||||
reqUser: UserDocument;
|
||||
}) {
|
||||
const { data, error } = useApiQuery<Array<ImportDocument>>(
|
||||
`/users/${reqUser.id}/imports?${params.toString()}`
|
||||
@@ -98,7 +98,7 @@ function ViewRecentFailedImports({
|
||||
reqUser,
|
||||
}: {
|
||||
params: URLSearchParams;
|
||||
reqUser: PublicUserDocument;
|
||||
reqUser: UserDocument;
|
||||
}) {
|
||||
const { data, error } = useApiQuery<Array<ImportTrackerFailed>>(
|
||||
`/users/${reqUser.id}/imports/failed?${params.toString()}`
|
||||
|
||||
@@ -19,7 +19,7 @@ import {
|
||||
APIPermissions,
|
||||
APITokenDocument,
|
||||
integer,
|
||||
PublicUserDocument,
|
||||
UserDocument,
|
||||
TachiAPIClientDocument,
|
||||
} from "tachi-common";
|
||||
import { SetState } from "types/react";
|
||||
@@ -27,7 +27,7 @@ import ARCIntegrationPage from "./ARCIntegrationPage";
|
||||
import FervidexIntegrationPage from "./FervidexIntegrationPage";
|
||||
import KsHookSV6CIntegrationPage from "./KsHookSV6CIntegrationPage";
|
||||
|
||||
export default function UserIntegrationsPage({ reqUser }: { reqUser: PublicUserDocument }) {
|
||||
export default function UserIntegrationsPage({ reqUser }: { reqUser: UserDocument }) {
|
||||
const [page, setPage] = useState<"services" | "api-keys" | "oauth-clients">("api-keys");
|
||||
|
||||
useSetSubheader(
|
||||
@@ -616,7 +616,7 @@ function EditClientModal({
|
||||
);
|
||||
}
|
||||
|
||||
function ServicesPage({ reqUser }: { reqUser: PublicUserDocument }) {
|
||||
function ServicesPage({ reqUser }: { reqUser: UserDocument }) {
|
||||
if (mode === "btchi") {
|
||||
return (
|
||||
<Row className="text-center">
|
||||
@@ -749,7 +749,7 @@ function KAIIntegrationStatus({
|
||||
);
|
||||
}
|
||||
|
||||
function APIKeysPage({ reqUser }: { reqUser: PublicUserDocument }) {
|
||||
function APIKeysPage({ reqUser }: { reqUser: UserDocument }) {
|
||||
const [apiKeys, setApiKeys] = useState<APITokenDocument[]>([]);
|
||||
const [showModal, setShowModal] = useState(false);
|
||||
|
||||
@@ -817,7 +817,7 @@ function CreateAPIKeyModal({
|
||||
}: {
|
||||
showModal: boolean;
|
||||
setShowModal: SetState<boolean>;
|
||||
reqUser: PublicUserDocument;
|
||||
reqUser: UserDocument;
|
||||
apiKeys: APITokenDocument[];
|
||||
setApiKeys: SetState<APITokenDocument[]>;
|
||||
}) {
|
||||
|
||||
@@ -11,10 +11,10 @@ import useApiQuery from "components/util/query/useApiQuery";
|
||||
import React from "react";
|
||||
import { Button, Col, Row } from "react-bootstrap";
|
||||
import { Link } from "react-router-dom";
|
||||
import { integer, InviteCodeDocument, PublicUserDocument } from "tachi-common";
|
||||
import { integer, InviteCodeDocument, UserDocument } from "tachi-common";
|
||||
import Icon from "components/util/Icon";
|
||||
|
||||
export default function UserInvitesPage({ reqUser }: { reqUser: PublicUserDocument }) {
|
||||
export default function UserInvitesPage({ reqUser }: { reqUser: UserDocument }) {
|
||||
useSetSubheader(
|
||||
["Users", reqUser.username, "Invites"],
|
||||
[reqUser],
|
||||
@@ -86,10 +86,10 @@ export default function UserInvitesPage({ reqUser }: { reqUser: PublicUserDocume
|
||||
);
|
||||
}
|
||||
|
||||
function InviteList({ reqUser }: { reqUser: PublicUserDocument }) {
|
||||
function InviteList({ reqUser }: { reqUser: UserDocument }) {
|
||||
const { data, error } = useApiQuery<{
|
||||
invites: InviteCodeDocument[];
|
||||
consumers: PublicUserDocument[];
|
||||
consumers: UserDocument[];
|
||||
}>(`/users/${reqUser.id}/invites`);
|
||||
|
||||
if (error) {
|
||||
|
||||
@@ -8,10 +8,10 @@ import { UserContext } from "context/UserContext";
|
||||
import React, { useContext, useEffect, useState } from "react";
|
||||
import { Button } from "react-bootstrap";
|
||||
import ReactMarkdown from "react-markdown";
|
||||
import { PublicUserDocument } from "tachi-common";
|
||||
import { UserDocument } from "tachi-common";
|
||||
|
||||
interface Props {
|
||||
reqUser: PublicUserDocument;
|
||||
reqUser: UserDocument;
|
||||
}
|
||||
|
||||
export default function UserPage({ reqUser }: Props) {
|
||||
|
||||
@@ -12,10 +12,10 @@ import { useFormik } from "formik";
|
||||
import { TachiConfig } from "lib/config";
|
||||
import React, { useContext, useState } from "react";
|
||||
import { Alert, Button, Form } from "react-bootstrap";
|
||||
import { PublicUserDocument, UserSettings } from "tachi-common";
|
||||
import { UserDocument, UserSettings } from "tachi-common";
|
||||
|
||||
interface Props {
|
||||
reqUser: PublicUserDocument;
|
||||
reqUser: UserDocument;
|
||||
}
|
||||
|
||||
export default function UserSettingsPage({ reqUser }: Props) {
|
||||
@@ -74,7 +74,7 @@ export default function UserSettingsPage({ reqUser }: Props) {
|
||||
);
|
||||
}
|
||||
|
||||
function AccountSettings({ reqUser }: { reqUser: PublicUserDocument }) {
|
||||
function AccountSettings({ reqUser }: { reqUser: UserDocument }) {
|
||||
const formik = useFormik({
|
||||
initialValues: {
|
||||
"!oldPassword": "",
|
||||
@@ -162,7 +162,7 @@ function AccountSettings({ reqUser }: { reqUser: PublicUserDocument }) {
|
||||
);
|
||||
}
|
||||
|
||||
function PreferencesForm({ reqUser }: { reqUser: PublicUserDocument }) {
|
||||
function PreferencesForm({ reqUser }: { reqUser: UserDocument }) {
|
||||
const { settings, setSettings } = useContext(UserSettingsContext);
|
||||
|
||||
const formik = useFormik({
|
||||
@@ -252,7 +252,7 @@ function PreferencesForm({ reqUser }: { reqUser: PublicUserDocument }) {
|
||||
);
|
||||
}
|
||||
|
||||
function ImageForm({ reqUser }: { reqUser: PublicUserDocument }) {
|
||||
function ImageForm({ reqUser }: { reqUser: UserDocument }) {
|
||||
const [pfp, setPfp] = useState<File | undefined>();
|
||||
const [banner, setBanner] = useState<File | undefined>();
|
||||
|
||||
@@ -313,7 +313,7 @@ function ImageForm({ reqUser }: { reqUser: PublicUserDocument }) {
|
||||
);
|
||||
}
|
||||
|
||||
function SocialMediaForm({ reqUser }: { reqUser: PublicUserDocument }) {
|
||||
function SocialMediaForm({ reqUser }: { reqUser: UserDocument }) {
|
||||
const placeholders = {
|
||||
discord: "Example#0000",
|
||||
twitter: "Twitter Handle",
|
||||
@@ -340,7 +340,7 @@ function SocialMediaForm({ reqUser }: { reqUser: PublicUserDocument }) {
|
||||
valuesClone[vx] = values[vx] || null;
|
||||
}
|
||||
|
||||
const rj = await APIFetchV1<PublicUserDocument>(
|
||||
const rj = await APIFetchV1<UserDocument>(
|
||||
"/users/me",
|
||||
{
|
||||
method: "PATCH",
|
||||
@@ -423,7 +423,7 @@ function FileUploadController({
|
||||
}: {
|
||||
file?: File;
|
||||
type: "pfp" | "banner";
|
||||
reqUser: PublicUserDocument;
|
||||
reqUser: UserDocument;
|
||||
}) {
|
||||
return (
|
||||
<div className="d-flex mt-8">
|
||||
|
||||
@@ -18,7 +18,7 @@ import {
|
||||
GetGamePTConfig,
|
||||
IDStrings,
|
||||
integer,
|
||||
PublicUserDocument,
|
||||
UserDocument,
|
||||
UGSRatingsLookup,
|
||||
UserGameStats,
|
||||
} from "tachi-common";
|
||||
@@ -35,7 +35,7 @@ export default function LeaderboardsPage({
|
||||
reqUser,
|
||||
game,
|
||||
playtype,
|
||||
}: { reqUser: PublicUserDocument } & GamePT) {
|
||||
}: { reqUser: UserDocument } & GamePT) {
|
||||
const gameConfig = GetGameConfig(game);
|
||||
useSetSubheader(
|
||||
["Users", reqUser.username, "Games", gameConfig.name, playtype, "Leaderboard"],
|
||||
@@ -86,7 +86,7 @@ function LeaderboardsPageContent({
|
||||
data,
|
||||
alg,
|
||||
}: {
|
||||
reqUser: PublicUserDocument;
|
||||
reqUser: UserDocument;
|
||||
data: LeaderboardsData;
|
||||
alg: UGSRatingsLookup[IDStrings];
|
||||
setAlg: SetState<UGSRatingsLookup[IDStrings]>;
|
||||
@@ -95,7 +95,7 @@ function LeaderboardsPageContent({
|
||||
|
||||
const gptConfig = GetGamePTConfig(game, playtype);
|
||||
|
||||
const userMap = new Map<integer, PublicUserDocument>();
|
||||
const userMap = new Map<integer, UserDocument>();
|
||||
|
||||
for (const u of stats.users) {
|
||||
userMap.set(u.id, u);
|
||||
|
||||
@@ -23,7 +23,7 @@ import {
|
||||
FormatGame,
|
||||
GetGameConfig,
|
||||
GetGamePTConfig,
|
||||
PublicUserDocument,
|
||||
UserDocument,
|
||||
ScoreDocument,
|
||||
SessionDocument,
|
||||
UserGameStats,
|
||||
@@ -37,7 +37,7 @@ export default function OverviewPage({
|
||||
reqUser,
|
||||
game,
|
||||
playtype,
|
||||
}: { reqUser: PublicUserDocument } & GamePT) {
|
||||
}: { reqUser: UserDocument } & GamePT) {
|
||||
const gameConfig = GetGameConfig(game);
|
||||
useSetSubheader(
|
||||
["Users", reqUser.username, "Games", gameConfig.name, playtype],
|
||||
@@ -54,7 +54,7 @@ export default function OverviewPage({
|
||||
);
|
||||
}
|
||||
|
||||
function LastSession({ reqUser, game, playtype }: { reqUser: PublicUserDocument } & GamePT) {
|
||||
function LastSession({ reqUser, game, playtype }: { reqUser: UserDocument } & GamePT) {
|
||||
return (
|
||||
<AsyncLoader
|
||||
promiseFn={async () => {
|
||||
@@ -170,7 +170,7 @@ function RecentSessionScoreInfo({
|
||||
}: {
|
||||
session: SessionDocument;
|
||||
sessionData: SessionReturns;
|
||||
reqUser: PublicUserDocument;
|
||||
reqUser: UserDocument;
|
||||
}) {
|
||||
const { game, playtype } = session;
|
||||
|
||||
@@ -249,7 +249,7 @@ function RecentSessionScoreInfo({
|
||||
);
|
||||
}
|
||||
|
||||
function RankingInfo({ reqUser, game, playtype }: { reqUser: PublicUserDocument } & GamePT) {
|
||||
function RankingInfo({ reqUser, game, playtype }: { reqUser: UserDocument } & GamePT) {
|
||||
return (
|
||||
<AsyncLoader
|
||||
promiseFn={async () => {
|
||||
@@ -274,7 +274,7 @@ function UserHistory({
|
||||
reqUser,
|
||||
game,
|
||||
playtype,
|
||||
}: { data: UGPTHistory; reqUser: PublicUserDocument } & GamePT) {
|
||||
}: { data: UGPTHistory; reqUser: UserDocument } & GamePT) {
|
||||
const gptConfig = GetGamePTConfig(game, playtype);
|
||||
|
||||
const [mode, setMode] = useState<"ranking" | "playcount" | "rating">("rating");
|
||||
|
||||
@@ -20,7 +20,7 @@ import {
|
||||
GetGamePTConfig,
|
||||
IDStrings,
|
||||
PBScoreDocument,
|
||||
PublicUserDocument,
|
||||
UserDocument,
|
||||
ScoreCalculatedDataLookup,
|
||||
ScoreDocument,
|
||||
SongDocument,
|
||||
@@ -34,7 +34,7 @@ export default function ScoresPage({
|
||||
game,
|
||||
playtype,
|
||||
}: {
|
||||
reqUser: PublicUserDocument;
|
||||
reqUser: UserDocument;
|
||||
} & GamePT) {
|
||||
const gameConfig = GetGameConfig(game);
|
||||
const gptConfig = GetGamePTConfig(game, playtype);
|
||||
@@ -141,7 +141,7 @@ function AlgSelector({
|
||||
);
|
||||
}
|
||||
|
||||
function useFetchPBs(url: string, reqUser: PublicUserDocument) {
|
||||
function useFetchPBs(url: string, reqUser: UserDocument) {
|
||||
const { data, error } = useQuery(url, async () => {
|
||||
const res = await APIFetchV1<{
|
||||
pbs: PBScoreDocument<"iidx:SP">[];
|
||||
@@ -168,7 +168,7 @@ function PBsOverview({
|
||||
url,
|
||||
alg,
|
||||
}: {
|
||||
reqUser: PublicUserDocument;
|
||||
reqUser: UserDocument;
|
||||
url: string;
|
||||
indexCol?: boolean;
|
||||
showPlaycount?: boolean;
|
||||
@@ -214,7 +214,7 @@ function FormatData<
|
||||
D extends PBScoreDocument | ScoreDocument,
|
||||
I extends IDStrings = IDStrings,
|
||||
G extends Game = Game
|
||||
>(d: D[], songs: SongDocument<G>[], charts: ChartDocument<I>[], reqUser: PublicUserDocument) {
|
||||
>(d: D[], songs: SongDocument<G>[], charts: ChartDocument<I>[], reqUser: UserDocument) {
|
||||
const songMap = new Map();
|
||||
const chartMap = new Map();
|
||||
|
||||
@@ -239,7 +239,7 @@ function FormatData<
|
||||
return data;
|
||||
}
|
||||
|
||||
function useFetchScores(url: string, reqUser: PublicUserDocument) {
|
||||
function useFetchScores(url: string, reqUser: UserDocument) {
|
||||
const { data, error } = useQuery(url, async () => {
|
||||
const res = await APIFetchV1<{
|
||||
scores: ScoreDocument[];
|
||||
@@ -264,7 +264,7 @@ function PBsSearch({
|
||||
search,
|
||||
alg,
|
||||
}: {
|
||||
reqUser: PublicUserDocument;
|
||||
reqUser: UserDocument;
|
||||
search: string;
|
||||
alg?: ScoreCalculatedDataLookup[IDStrings];
|
||||
} & GamePT) {
|
||||
@@ -286,7 +286,7 @@ function PBsSearch({
|
||||
);
|
||||
}
|
||||
|
||||
function ScoresOverview({ reqUser, game, playtype }: { reqUser: PublicUserDocument } & GamePT) {
|
||||
function ScoresOverview({ reqUser, game, playtype }: { reqUser: UserDocument } & GamePT) {
|
||||
const [search, setSearch] = useState("");
|
||||
|
||||
const { data, error } = useFetchScores(
|
||||
@@ -321,7 +321,7 @@ function ScoresSearch({
|
||||
game,
|
||||
playtype,
|
||||
search,
|
||||
}: { reqUser: PublicUserDocument; search: string } & GamePT) {
|
||||
}: { reqUser: UserDocument; search: string } & GamePT) {
|
||||
const { data, error } = useFetchScores(
|
||||
`/users/${reqUser.id}/games/${game}/${playtype}/scores?search=${search}`,
|
||||
reqUser
|
||||
|
||||
@@ -14,7 +14,7 @@ import { useQuery } from "react-query";
|
||||
import {
|
||||
FormatGame,
|
||||
GetGameConfig,
|
||||
PublicUserDocument,
|
||||
UserDocument,
|
||||
SessionDocument,
|
||||
UnsuccessfulAPIResponse,
|
||||
} from "tachi-common";
|
||||
@@ -25,7 +25,7 @@ export default function SessionsPage({
|
||||
game,
|
||||
playtype,
|
||||
}: {
|
||||
reqUser: PublicUserDocument;
|
||||
reqUser: UserDocument;
|
||||
} & GamePT) {
|
||||
const [sessionSet, setSessionSet] = useState<"recent" | "best" | "highlighted">("best");
|
||||
const [search, setSearch] = useState("");
|
||||
@@ -116,7 +116,7 @@ function SearchSessionsTable({
|
||||
playtype,
|
||||
reqUser,
|
||||
baseUrl,
|
||||
}: { search: string; baseUrl: string; reqUser: PublicUserDocument } & GamePT) {
|
||||
}: { search: string; baseUrl: string; reqUser: UserDocument } & GamePT) {
|
||||
const { data, error } = useQuery<SessionDataset, UnsuccessfulAPIResponse>(
|
||||
`${baseUrl}?search=${search}`,
|
||||
async () => {
|
||||
|
||||
@@ -15,11 +15,11 @@ import { UserContext } from "context/UserContext";
|
||||
import React, { useContext, useMemo, useState } from "react";
|
||||
import { Badge, Button, Col, Form, Modal, Row } from "react-bootstrap";
|
||||
import { Redirect, useParams } from "react-router-dom";
|
||||
import { GetGameConfig, PublicUserDocument, SessionDocument } from "tachi-common";
|
||||
import { GetGameConfig, UserDocument, SessionDocument } from "tachi-common";
|
||||
import { SessionReturns } from "types/api-returns";
|
||||
import { GamePT, SetState } from "types/react";
|
||||
|
||||
type Props = { reqUser: PublicUserDocument } & GamePT;
|
||||
type Props = { reqUser: UserDocument } & GamePT;
|
||||
|
||||
export default function SpecificSessionPage({ reqUser, game, playtype }: Props) {
|
||||
const { sessionID } = useParams<{ sessionID: string }>();
|
||||
|
||||
@@ -22,7 +22,7 @@ import {
|
||||
FormatGame,
|
||||
GetGameConfig,
|
||||
GetGamePTConfig,
|
||||
PublicUserDocument,
|
||||
UserDocument,
|
||||
ShowcaseStatDetails,
|
||||
TableDocument,
|
||||
UGPTSettings,
|
||||
@@ -31,7 +31,7 @@ import { GamePT, SetState } from "types/react";
|
||||
import { UGPTContext } from "context/UGPTContext";
|
||||
import { ErrorPage } from "app/pages/ErrorPage";
|
||||
|
||||
type Props = { reqUser: PublicUserDocument } & GamePT;
|
||||
type Props = { reqUser: UserDocument } & GamePT;
|
||||
|
||||
export default function UGPTSettingsPage({ reqUser, game, playtype }: Props) {
|
||||
const query = useQueryString();
|
||||
@@ -108,7 +108,7 @@ function PreferencesForm({ reqUser, game, playtype }: Props) {
|
||||
preferredRanking: settings!.preferences.preferredRanking ?? "global",
|
||||
},
|
||||
onSubmit: async (values) => {
|
||||
const rj = await APIFetchV1<PublicUserDocument>(
|
||||
const rj = await APIFetchV1<UserDocument>(
|
||||
`/users/${reqUser.id}/games/${game}/${playtype}/settings`,
|
||||
{
|
||||
method: "PATCH",
|
||||
|
||||
+6
-6
@@ -11,7 +11,7 @@ import useLUGPTSettings from "components/util/useLUGPTSettings";
|
||||
import React, { useContext, useEffect, useMemo, useState } from "react";
|
||||
import { Button, Col, Form, Row } from "react-bootstrap";
|
||||
import { Link } from "react-router-dom";
|
||||
import { COLOUR_SET, FolderDocument, GetGamePTConfig, PublicUserDocument } from "tachi-common";
|
||||
import { COLOUR_SET, FolderDocument, GetGamePTConfig, UserDocument } from "tachi-common";
|
||||
import { UGPTFolderReturns, UGPTStatsReturn } from "types/api-returns";
|
||||
import { GamePT } from "types/react";
|
||||
import { ComparePBsDataset } from "types/tables";
|
||||
@@ -26,17 +26,17 @@ export default function RivalCompareFolderPage({
|
||||
playtype,
|
||||
folder,
|
||||
}: GamePT & {
|
||||
reqUser: PublicUserDocument;
|
||||
reqUser: UserDocument;
|
||||
folder: FolderDocument;
|
||||
}) {
|
||||
const { settings } = useLUGPTSettings();
|
||||
const { user } = useContext(UserContext);
|
||||
|
||||
const [selectedUser, setSelectedUser] = useState<PublicUserDocument | null>(null);
|
||||
const [selectedUser, setSelectedUser] = useState<UserDocument | null>(null);
|
||||
const [show, setShow] = useState(false);
|
||||
|
||||
// honestly don't care if this errors or not
|
||||
const { data, error } = useApiQuery<Array<PublicUserDocument>>(
|
||||
const { data, error } = useApiQuery<Array<UserDocument>>(
|
||||
`/users/${settings?.userID}/games/${game}/${playtype}/rivals`,
|
||||
undefined
|
||||
// [settings?.rivals.join(",")]
|
||||
@@ -121,8 +121,8 @@ function FolderCompare({
|
||||
withUser,
|
||||
folder,
|
||||
}: {
|
||||
reqUser: PublicUserDocument;
|
||||
withUser: PublicUserDocument;
|
||||
reqUser: UserDocument;
|
||||
withUser: UserDocument;
|
||||
folder: FolderDocument;
|
||||
} & GamePT) {
|
||||
const gptConfig = GetGamePTConfig(game, playtype);
|
||||
|
||||
+2
-2
@@ -13,11 +13,11 @@ import { useBucket } from "components/util/useBucket";
|
||||
import useUGPTBase from "components/util/useUGPTBase";
|
||||
import { UserContext } from "context/UserContext";
|
||||
import React, { useContext, useMemo, useState } from "react";
|
||||
import { FolderDocument, GetGamePTConfig, PublicUserDocument } from "tachi-common";
|
||||
import { FolderDocument, GetGamePTConfig, UserDocument } from "tachi-common";
|
||||
import { FolderStatsInfo, UGPTFolderSearch } from "types/api-returns";
|
||||
import { GamePT } from "types/react";
|
||||
|
||||
type Props = { reqUser: PublicUserDocument } & GamePT;
|
||||
type Props = { reqUser: UserDocument } & GamePT;
|
||||
|
||||
export default function FoldersSearch({ reqUser, game, playtype }: Props) {
|
||||
const [search, setSearch] = useState("");
|
||||
|
||||
+2
-2
@@ -25,14 +25,14 @@ import {
|
||||
Game,
|
||||
GamePTConfig,
|
||||
GetGamePTConfig,
|
||||
PublicUserDocument,
|
||||
UserDocument,
|
||||
TableDocument,
|
||||
} from "tachi-common";
|
||||
import { FolderStatsInfo, UGPTTableReturns } from "types/api-returns";
|
||||
import { Playtype } from "types/tachi";
|
||||
|
||||
interface Props {
|
||||
reqUser: PublicUserDocument;
|
||||
reqUser: UserDocument;
|
||||
game: Game;
|
||||
playtype: Playtype;
|
||||
}
|
||||
|
||||
+2
-2
@@ -7,14 +7,14 @@ import { UserContext } from "context/UserContext";
|
||||
import { AllLUGPTStatsContext } from "context/AllLUGPTStatsContext";
|
||||
import React, { useContext } from "react";
|
||||
import { Route, Switch } from "react-router-dom";
|
||||
import { FormatGame, GetGameConfig, PublicUserDocument } from "tachi-common";
|
||||
import { FormatGame, GetGameConfig, UserDocument } from "tachi-common";
|
||||
import { GamePT } from "types/react";
|
||||
import FolderSelectPage from "./FolderSelectPage";
|
||||
import FolderTablePage from "./FolderTablePage";
|
||||
import RecentFoldersPage from "./RecentFoldersPage";
|
||||
import SpecificFolderPage from "./SpecificFolderPage";
|
||||
|
||||
type Props = { reqUser: PublicUserDocument } & GamePT;
|
||||
type Props = { reqUser: UserDocument } & GamePT;
|
||||
|
||||
export default function FoldersMainPage({ reqUser, game, playtype }: Props) {
|
||||
const gameConfig = GetGameConfig(game);
|
||||
|
||||
+2
-2
@@ -5,7 +5,7 @@ import { UserContext } from "context/UserContext";
|
||||
import React, { useContext } from "react";
|
||||
import { Row } from "react-bootstrap";
|
||||
import { Link } from "react-router-dom";
|
||||
import { FolderDocument, PublicUserDocument, RecentlyViewedFolderDocument } from "tachi-common";
|
||||
import { FolderDocument, UserDocument, RecentlyViewedFolderDocument } from "tachi-common";
|
||||
import { FolderStatsInfo } from "types/api-returns";
|
||||
import { GamePT } from "types/react";
|
||||
import { FolderInfoComponent } from "./FolderSelectPage";
|
||||
@@ -14,7 +14,7 @@ export default function RecentFoldersPage({
|
||||
reqUser,
|
||||
game,
|
||||
playtype,
|
||||
}: { reqUser: PublicUserDocument } & GamePT) {
|
||||
}: { reqUser: UserDocument } & GamePT) {
|
||||
const { user } = useContext(UserContext);
|
||||
|
||||
if (!user) {
|
||||
|
||||
+4
-4
@@ -31,7 +31,7 @@ import {
|
||||
GPTTierlists,
|
||||
IDStrings,
|
||||
integer,
|
||||
PublicUserDocument,
|
||||
UserDocument,
|
||||
ScoreDocument,
|
||||
SongDocument,
|
||||
} from "tachi-common";
|
||||
@@ -41,7 +41,7 @@ import { Playtype } from "types/tachi";
|
||||
import FolderComparePage from "./FolderComparePage";
|
||||
|
||||
interface Props {
|
||||
reqUser: PublicUserDocument;
|
||||
reqUser: UserDocument;
|
||||
game: Game;
|
||||
playtype: Playtype;
|
||||
}
|
||||
@@ -481,7 +481,7 @@ function TierlistInfoLadder({
|
||||
dataMap: Map<string, FolderDataset[0]>;
|
||||
game: Game;
|
||||
playtype: Playtype;
|
||||
reqUser: PublicUserDocument;
|
||||
reqUser: UserDocument;
|
||||
}) {
|
||||
const buckets: TierlistInfo[][] = useMemo(() => {
|
||||
const buckets: TierlistInfo[][] = [];
|
||||
@@ -579,7 +579,7 @@ function TierlistInfoBucketValues({
|
||||
dataMap: Map<string, FolderDataset[0]>;
|
||||
game: Game;
|
||||
i: integer;
|
||||
reqUser: PublicUserDocument;
|
||||
reqUser: UserDocument;
|
||||
}) {
|
||||
const data = dataMap.get(tierlistInfo.chartID)!;
|
||||
|
||||
|
||||
+2
-2
@@ -8,7 +8,7 @@ import useUGPTBase from "components/util/useUGPTBase";
|
||||
import React from "react";
|
||||
import { Col, Row } from "react-bootstrap";
|
||||
import { Redirect, Route, Switch } from "react-router-dom";
|
||||
import { FormatGame, Game, GetGameConfig, Playtype, PublicUserDocument } from "tachi-common";
|
||||
import { FormatGame, Game, GetGameConfig, Playtype, UserDocument } from "tachi-common";
|
||||
import RivalsManagePage from "./RivalsManagePage";
|
||||
|
||||
export default function RivalsMainPage({
|
||||
@@ -16,7 +16,7 @@ export default function RivalsMainPage({
|
||||
game,
|
||||
playtype,
|
||||
}: {
|
||||
reqUser: PublicUserDocument;
|
||||
reqUser: UserDocument;
|
||||
game: Game;
|
||||
playtype: Playtype;
|
||||
}) {
|
||||
|
||||
+7
-7
@@ -12,7 +12,7 @@ import UserIcon from "components/util/UserIcon";
|
||||
import { UserContext } from "context/UserContext";
|
||||
import React, { useContext, useState } from "react";
|
||||
import { Button, Col } from "react-bootstrap";
|
||||
import { FormatGame, Game, GetGameConfig, Playtype, PublicUserDocument } from "tachi-common";
|
||||
import { FormatGame, Game, GetGameConfig, Playtype, UserDocument } from "tachi-common";
|
||||
import useLUGPTSettings from "components/util/useLUGPTSettings";
|
||||
import useSetSubheader from "components/layout/header/useSetSubheader";
|
||||
|
||||
@@ -21,7 +21,7 @@ export default function RivalsManagePage({
|
||||
game,
|
||||
playtype,
|
||||
}: {
|
||||
reqUser: PublicUserDocument;
|
||||
reqUser: UserDocument;
|
||||
game: Game;
|
||||
playtype: Playtype;
|
||||
}) {
|
||||
@@ -35,7 +35,7 @@ export default function RivalsManagePage({
|
||||
|
||||
const { settings } = useLUGPTSettings();
|
||||
|
||||
const { data, error } = useApiQuery<PublicUserDocument[]>(
|
||||
const { data, error } = useApiQuery<UserDocument[]>(
|
||||
`/users/${reqUser.id}/games/${game}/${playtype}/rivals`,
|
||||
{},
|
||||
[`fetch-rivals-${settings?.rivals.join(",")}`]
|
||||
@@ -45,7 +45,7 @@ export default function RivalsManagePage({
|
||||
data: challengers,
|
||||
isLoading: cIsLoading,
|
||||
error: cError,
|
||||
} = useApiQuery<PublicUserDocument[]>(
|
||||
} = useApiQuery<UserDocument[]>(
|
||||
`/users/${reqUser.id}/games/${game}/${playtype}/rivals/challengers`
|
||||
);
|
||||
|
||||
@@ -83,11 +83,11 @@ function RivalsOverviewPage({
|
||||
initialRivals,
|
||||
challengers,
|
||||
}: {
|
||||
reqUser: PublicUserDocument;
|
||||
reqUser: UserDocument;
|
||||
game: Game;
|
||||
playtype: Playtype;
|
||||
initialRivals: Array<PublicUserDocument>;
|
||||
challengers: Array<PublicUserDocument>;
|
||||
initialRivals: Array<UserDocument>;
|
||||
challengers: Array<UserDocument>;
|
||||
}) {
|
||||
const { user } = useContext(UserContext);
|
||||
|
||||
|
||||
@@ -6,11 +6,11 @@ import useUGPTBase from "components/util/useUGPTBase";
|
||||
import React from "react";
|
||||
import { Col, Row } from "react-bootstrap";
|
||||
import { Route, Switch } from "react-router-dom";
|
||||
import { FormatGame, GetGameConfig, PublicUserDocument } from "tachi-common";
|
||||
import { FormatGame, GetGameConfig, UserDocument } from "tachi-common";
|
||||
import { GamePT } from "types/react";
|
||||
import GoalsPage from "./GoalsPage";
|
||||
|
||||
type Props = { reqUser: PublicUserDocument } & GamePT;
|
||||
type Props = { reqUser: UserDocument } & GamePT;
|
||||
|
||||
export default function TargetsPage({ reqUser, game, playtype }: Props) {
|
||||
const gameConfig = GetGameConfig(game);
|
||||
|
||||
@@ -27,7 +27,7 @@ import { UserSettingsContext } from "context/UserSettingsContext";
|
||||
import React, { useContext, useEffect } from "react";
|
||||
import { useQuery } from "react-query";
|
||||
import { Redirect, Route, Switch, useHistory, useParams } from "react-router-dom";
|
||||
import { FormatGame, Game, GetGameConfig, PublicUserDocument, UserGameStats } from "tachi-common";
|
||||
import { FormatGame, Game, GetGameConfig, UserDocument, UserGameStats } from "tachi-common";
|
||||
import { UGPTStatsReturn } from "types/api-returns";
|
||||
import UserImportsPage from "app/pages/dashboard/users/UserImportsPage";
|
||||
import ScoresPage from "../pages/dashboard/users/games/_game/_playtype/ScoresPage";
|
||||
@@ -38,7 +38,7 @@ export default function UserRoutes() {
|
||||
const { userID } = useParams<{ userID: string }>();
|
||||
const history = useHistory();
|
||||
|
||||
const { data: reqUser, error } = useApiQuery<PublicUserDocument>(`/users/${params.userID}`);
|
||||
const { data: reqUser, error } = useApiQuery<UserDocument>(`/users/${params.userID}`);
|
||||
|
||||
const { setBackground } = useContext(BackgroundContext);
|
||||
useEffect(() => {
|
||||
@@ -95,7 +95,7 @@ export default function UserRoutes() {
|
||||
);
|
||||
}
|
||||
|
||||
function UserProfileRoutes({ reqUser }: { reqUser: PublicUserDocument }) {
|
||||
function UserProfileRoutes({ reqUser }: { reqUser: UserDocument }) {
|
||||
const { settings } = useContext(UserSettingsContext);
|
||||
|
||||
return (
|
||||
@@ -145,7 +145,7 @@ function UserProfileRoutes({ reqUser }: { reqUser: PublicUserDocument }) {
|
||||
);
|
||||
}
|
||||
|
||||
function UserGameRoutes({ reqUser }: { reqUser: PublicUserDocument }) {
|
||||
function UserGameRoutes({ reqUser }: { reqUser: UserDocument }) {
|
||||
const { game } = useParams<{ game: string }>();
|
||||
|
||||
if (!IsSupportedGame(game)) {
|
||||
@@ -180,7 +180,7 @@ function UserGameRoutes({ reqUser }: { reqUser: PublicUserDocument }) {
|
||||
);
|
||||
}
|
||||
|
||||
function UserGamePlaytypeRoutes({ reqUser, game }: { reqUser: PublicUserDocument; game: Game }) {
|
||||
function UserGamePlaytypeRoutes({ reqUser, game }: { reqUser: UserDocument; game: Game }) {
|
||||
const { playtype } = useParams<{ playtype: string }>();
|
||||
|
||||
if (!IsSupportedPlaytype(game, playtype)) {
|
||||
|
||||
@@ -4,7 +4,7 @@ import Icon from "components/util/Icon";
|
||||
import SelectButton from "components/util/SelectButton";
|
||||
import { useBucket } from "components/util/useBucket";
|
||||
import React, { useState } from "react";
|
||||
import { PublicUserDocument } from "tachi-common";
|
||||
import { UserDocument } from "tachi-common";
|
||||
import { GamePT } from "types/react";
|
||||
import { FolderDataset } from "types/tables";
|
||||
import FolderMinimap from "./FolderMinimap";
|
||||
@@ -17,7 +17,7 @@ export default function FolderInfoHeader({
|
||||
folderDataset,
|
||||
folderTitle,
|
||||
}: {
|
||||
reqUser: PublicUserDocument;
|
||||
reqUser: UserDocument;
|
||||
folderDataset: FolderDataset;
|
||||
folderTitle: string;
|
||||
} & GamePT) {
|
||||
|
||||
@@ -17,7 +17,7 @@ import {
|
||||
GamePTConfig,
|
||||
GetGamePTConfig,
|
||||
IIDX_LAMPS,
|
||||
PublicUserDocument,
|
||||
UserDocument,
|
||||
SessionDocument,
|
||||
} from "tachi-common";
|
||||
import { GamePT } from "types/react";
|
||||
@@ -25,7 +25,7 @@ import { FolderDataset } from "types/tables";
|
||||
|
||||
type Props = {
|
||||
folderDataset: FolderDataset;
|
||||
reqUser: PublicUserDocument;
|
||||
reqUser: UserDocument;
|
||||
view: "grade" | "lamp";
|
||||
} & GamePT;
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ import {
|
||||
ChartDocument,
|
||||
Game,
|
||||
ImportDocument,
|
||||
PublicUserDocument,
|
||||
UserDocument,
|
||||
ScoreDocument,
|
||||
SessionDocument,
|
||||
SongDocument,
|
||||
@@ -32,7 +32,7 @@ interface Data {
|
||||
charts: ChartDocument[];
|
||||
songs: SongDocument[];
|
||||
sessions: SessionDocument[];
|
||||
user: PublicUserDocument;
|
||||
user: UserDocument;
|
||||
}
|
||||
|
||||
export default function ImportInfo({
|
||||
|
||||
@@ -6,13 +6,13 @@ import Loading from "components/util/Loading";
|
||||
import { TachiConfig } from "lib/config";
|
||||
import React, { useEffect, useMemo, useRef, useState } from "react";
|
||||
import { Link, useLocation } from "react-router-dom";
|
||||
import { Game, GetGameConfig, integer, PublicUserDocument, SongDocument } from "tachi-common";
|
||||
import { Game, GetGameConfig, integer, UserDocument, SongDocument } from "tachi-common";
|
||||
import { GamePT, JustChildren } from "types/react";
|
||||
import { Playtype } from "types/tachi";
|
||||
import QuickTooltip from "../misc/QuickTooltip";
|
||||
|
||||
interface SearchReturns {
|
||||
users?: PublicUserDocument[];
|
||||
users?: UserDocument[];
|
||||
songs: (SongDocument & { __textScore: number; game: Game })[];
|
||||
}
|
||||
|
||||
@@ -38,7 +38,7 @@ function GPTSearchResult({
|
||||
playtype,
|
||||
tabIndex,
|
||||
}: {
|
||||
user: PublicUserDocument;
|
||||
user: UserDocument;
|
||||
tabIndex: integer;
|
||||
} & GamePT) {
|
||||
const currentLoc = window.location.href.split(`games/${game}/${playtype}`)[1];
|
||||
|
||||
@@ -2,9 +2,9 @@ import Icon from "components/util/Icon";
|
||||
import useApiQuery from "components/util/query/useApiQuery";
|
||||
import React, { useMemo } from "react";
|
||||
import { Link } from "react-router-dom";
|
||||
import { NotificationDocument, PublicUserDocument } from "tachi-common";
|
||||
import { NotificationDocument, UserDocument } from "tachi-common";
|
||||
|
||||
export function UserNotificationButton({ user }: { user: PublicUserDocument }) {
|
||||
export function UserNotificationButton({ user }: { user: UserDocument }) {
|
||||
// don't care whether it errors or not, tbh
|
||||
const { data } = useApiQuery<Array<NotificationDocument>>(`/users/${user.id}/notifications`);
|
||||
|
||||
|
||||
@@ -10,9 +10,9 @@ import { Button } from "react-bootstrap";
|
||||
import Dropdown from "react-bootstrap/Dropdown";
|
||||
import toast from "react-hot-toast";
|
||||
import { Link } from "react-router-dom";
|
||||
import { PublicUserDocument } from "tachi-common";
|
||||
import { UserDocument } from "tachi-common";
|
||||
|
||||
export function UserProfileDropdown({ user }: { user: PublicUserDocument }) {
|
||||
export function UserProfileDropdown({ user }: { user: UserDocument }) {
|
||||
const { setUser } = useContext(UserContext);
|
||||
const [heySplash] = useState(RFA(heySplashes));
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ import { APIFetchV1 } from "util/api";
|
||||
import { UserContext } from "context/UserContext";
|
||||
import { TachiConfig } from "lib/config";
|
||||
import React, { useContext, useEffect, useState } from "react";
|
||||
import { PublicUserDocument } from "tachi-common";
|
||||
import { UserDocument } from "tachi-common";
|
||||
import { JustChildren } from "types/react";
|
||||
import { SplashScreen } from "./SplashScreen";
|
||||
|
||||
@@ -28,7 +28,7 @@ export function LoadingScreen({ children }: JustChildren) {
|
||||
);
|
||||
|
||||
Promise.all([
|
||||
APIFetchV1<PublicUserDocument>("/users/me").then((rj) => {
|
||||
APIFetchV1<UserDocument>("/users/me").then((rj) => {
|
||||
if (rj.success) {
|
||||
setUser(rj.body);
|
||||
} else {
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import { ToAPIURL } from "util/api";
|
||||
import React from "react";
|
||||
import { Link } from "react-router-dom";
|
||||
import { PublicUserDocument } from "tachi-common";
|
||||
import { UserDocument } from "tachi-common";
|
||||
import { GamePT } from "types/react";
|
||||
|
||||
export default function UserCell({ user, game, playtype }: { user: PublicUserDocument } & GamePT) {
|
||||
export default function UserCell({ user, game, playtype }: { user: UserDocument } & GamePT) {
|
||||
return (
|
||||
<td
|
||||
style={{
|
||||
|
||||
@@ -11,7 +11,7 @@ import {
|
||||
ChartDocument,
|
||||
IDStrings,
|
||||
PBScoreDocument,
|
||||
PublicUserDocument,
|
||||
UserDocument,
|
||||
ScoreDocument,
|
||||
} from "tachi-common";
|
||||
import { UGPTChartPBComposition } from "types/api-returns";
|
||||
@@ -43,7 +43,7 @@ export default function ScoreDropdown<I extends IDStrings = IDStrings>({
|
||||
thisScore,
|
||||
defaultView = "moreInfo",
|
||||
}: {
|
||||
user: PublicUserDocument;
|
||||
user: UserDocument;
|
||||
chart: ChartDocument;
|
||||
scoreState: ScoreState;
|
||||
defaultView?: "vsPB" | "moreInfo" | "history" | "debug" | "manage" | "rivals";
|
||||
|
||||
@@ -5,7 +5,7 @@ import React from "react";
|
||||
import {
|
||||
COLOUR_SET,
|
||||
GoalDocument,
|
||||
PublicUserDocument,
|
||||
UserDocument,
|
||||
GoalSubscriptionDocument,
|
||||
} from "tachi-common";
|
||||
import { GamePT } from "types/react";
|
||||
@@ -15,7 +15,7 @@ import TachiTable, { Header } from "../components/TachiTable";
|
||||
|
||||
export type GoalSubDataset = (GoalSubscriptionDocument & {
|
||||
__related: {
|
||||
user: PublicUserDocument;
|
||||
user: UserDocument;
|
||||
goal: GoalDocument;
|
||||
};
|
||||
})[];
|
||||
|
||||
@@ -10,7 +10,7 @@ import {
|
||||
GetGamePTConfig,
|
||||
IDStrings,
|
||||
integer,
|
||||
PublicUserDocument,
|
||||
UserDocument,
|
||||
SessionCalculatedDataLookup,
|
||||
SessionDocument,
|
||||
} from "tachi-common";
|
||||
@@ -30,7 +30,7 @@ export default function GenericSessionTable({
|
||||
}: {
|
||||
dataset: SessionDataset;
|
||||
indexCol?: boolean;
|
||||
reqUser: PublicUserDocument;
|
||||
reqUser: UserDocument;
|
||||
game: Game;
|
||||
playtype: Playtype;
|
||||
}) {
|
||||
@@ -108,7 +108,7 @@ function Row({
|
||||
data: SessionDataset[0];
|
||||
// reqUser: PublicUserDocument;
|
||||
rating: SessionCalculatedDataLookup[IDStrings];
|
||||
reqUser: PublicUserDocument;
|
||||
reqUser: UserDocument;
|
||||
indexCol?: boolean;
|
||||
}) {
|
||||
return (
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
import { ToAPIURL } from "util/api";
|
||||
import React from "react";
|
||||
import { PublicUserDocument } from "tachi-common";
|
||||
import { UserDocument } from "tachi-common";
|
||||
|
||||
export default function ProfilePicture({
|
||||
user,
|
||||
src,
|
||||
}: {
|
||||
user: PublicUserDocument | string;
|
||||
user: UserDocument | string;
|
||||
src?: string;
|
||||
}) {
|
||||
if (typeof user === "string") {
|
||||
|
||||
@@ -4,7 +4,7 @@ import NavItem from "components/nav/NavItem";
|
||||
import MiniTable from "components/tables/components/MiniTable";
|
||||
import Divider from "components/util/Divider";
|
||||
import React from "react";
|
||||
import { Game, PublicUserDocument } from "tachi-common";
|
||||
import { Game, UserDocument } from "tachi-common";
|
||||
import { UGPTStatsReturn } from "types/api-returns";
|
||||
import { Playtype } from "types/tachi";
|
||||
import ProfileBadges from "./ProfileBadges";
|
||||
@@ -18,7 +18,7 @@ export function UGPTHeaderBody({
|
||||
playtype,
|
||||
stats,
|
||||
}: {
|
||||
reqUser: PublicUserDocument;
|
||||
reqUser: UserDocument;
|
||||
game: Game;
|
||||
playtype: Playtype;
|
||||
stats: UGPTStatsReturn;
|
||||
|
||||
@@ -4,12 +4,12 @@ import useApiQuery from "components/util/query/useApiQuery";
|
||||
import { UserContext } from "context/UserContext";
|
||||
import React, { useContext } from "react";
|
||||
import { useQuery } from "react-query";
|
||||
import { integer, PublicUserDocument, ShowcaseStatDetails } from "tachi-common";
|
||||
import { integer, UserDocument, ShowcaseStatDetails } from "tachi-common";
|
||||
import { UGPTPreferenceStatsReturn } from "types/api-returns";
|
||||
import { GamePT } from "types/react";
|
||||
import { StatDisplay } from "./UGPTStatShowcase";
|
||||
|
||||
type Props = { reqUser: PublicUserDocument } & GamePT;
|
||||
type Props = { reqUser: UserDocument } & GamePT;
|
||||
|
||||
export default function UGPTStatContainer({
|
||||
stat,
|
||||
|
||||
@@ -8,7 +8,7 @@ import {
|
||||
FormatDifficulty,
|
||||
Game,
|
||||
GetGamePTConfig,
|
||||
PublicUserDocument,
|
||||
UserDocument,
|
||||
ShowcaseStatDetails,
|
||||
} from "tachi-common";
|
||||
import { GamePT, SetState } from "types/react";
|
||||
@@ -19,7 +19,7 @@ import Muted from "components/util/Muted";
|
||||
import { UserContext } from "context/UserContext";
|
||||
|
||||
interface Props {
|
||||
reqUser: PublicUserDocument;
|
||||
reqUser: UserDocument;
|
||||
game: Game;
|
||||
playtype: Playtype;
|
||||
onCreate: (stat: ShowcaseStatDetails) => void;
|
||||
|
||||
@@ -20,7 +20,7 @@ import {
|
||||
FormatChart,
|
||||
Game,
|
||||
GetGamePTConfig,
|
||||
PublicUserDocument,
|
||||
UserDocument,
|
||||
ShowcaseStatDetails,
|
||||
SongDocument,
|
||||
} from "tachi-common";
|
||||
@@ -34,7 +34,7 @@ export default function UGPTStatShowcase({
|
||||
reqUser,
|
||||
game,
|
||||
playtype,
|
||||
}: { reqUser: PublicUserDocument } & GamePT) {
|
||||
}: { reqUser: UserDocument } & GamePT) {
|
||||
const { ugs } = useContext(AllLUGPTStatsContext);
|
||||
const { user } = useContext(UserContext);
|
||||
|
||||
@@ -377,7 +377,7 @@ export function StatDisplay({
|
||||
}: {
|
||||
statData: UGPTPreferenceStatsReturn;
|
||||
compareData?: UGPTPreferenceStatsReturn;
|
||||
reqUser: PublicUserDocument;
|
||||
reqUser: UserDocument;
|
||||
} & GamePT) {
|
||||
const { stat, result, related } = statData;
|
||||
const { user } = useContext(UserContext);
|
||||
|
||||
@@ -10,12 +10,12 @@ import { UserContext } from "context/UserContext";
|
||||
import { ClientConfig } from "lib/config";
|
||||
import React, { useContext, useState } from "react";
|
||||
import { Button, Form, Modal } from "react-bootstrap";
|
||||
import { PublicUserDocument } from "tachi-common";
|
||||
import { UserDocument } from "tachi-common";
|
||||
import { SetState } from "types/react";
|
||||
import ProfileBadges from "./ProfileBadges";
|
||||
import ProfilePicture from "./ProfilePicture";
|
||||
|
||||
export function UserHeaderBody({ reqUser }: { reqUser: PublicUserDocument }) {
|
||||
export function UserHeaderBody({ reqUser }: { reqUser: UserDocument }) {
|
||||
function ConditionalSocialMediaRender({
|
||||
mode,
|
||||
href,
|
||||
@@ -87,7 +87,7 @@ export function UserBottomNav({
|
||||
reqUser,
|
||||
}: {
|
||||
baseUrl: string;
|
||||
reqUser: PublicUserDocument;
|
||||
reqUser: UserDocument;
|
||||
}) {
|
||||
const { user } = useContext(UserContext);
|
||||
|
||||
@@ -138,7 +138,7 @@ export function UserBottomNav({
|
||||
);
|
||||
}
|
||||
|
||||
function StatusComponent({ reqUser }: { reqUser: PublicUserDocument }) {
|
||||
function StatusComponent({ reqUser }: { reqUser: UserDocument }) {
|
||||
const { user } = useContext(UserContext);
|
||||
|
||||
const isRequestedUser = user?.id === reqUser.id;
|
||||
@@ -182,7 +182,7 @@ function ChangeStatusModal({
|
||||
}: {
|
||||
modalShow: boolean;
|
||||
setModalShow: SetState<boolean>;
|
||||
reqUser: PublicUserDocument;
|
||||
reqUser: UserDocument;
|
||||
}) {
|
||||
const [status, setStatus] = useState(reqUser.status);
|
||||
const [innerStatus, setInnerStatus] = useState(reqUser.status ?? "");
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import React from "react";
|
||||
import { PublicUserDocument, TachiAPIClientDocument } from "tachi-common";
|
||||
import { UserDocument, TachiAPIClientDocument } from "tachi-common";
|
||||
import ApiError from "./ApiError";
|
||||
import Loading from "./Loading";
|
||||
import Muted from "./Muted";
|
||||
@@ -10,7 +10,7 @@ export default function OAuthMoreInfo({
|
||||
}: {
|
||||
client: Omit<TachiAPIClientDocument, "clientSecret">;
|
||||
}) {
|
||||
const { data, error } = useApiQuery<PublicUserDocument>(`/users/${client.author}`);
|
||||
const { data, error } = useApiQuery<UserDocument>(`/users/${client.author}`);
|
||||
|
||||
if (error) {
|
||||
return <ApiError error={error} />;
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { UserContext } from "context/UserContext";
|
||||
import React, { useContext } from "react";
|
||||
import { PublicUserDocument } from "tachi-common";
|
||||
import { UserDocument } from "tachi-common";
|
||||
|
||||
export default function ReferToUser({ reqUser }: { reqUser: PublicUserDocument }) {
|
||||
export default function ReferToUser({ reqUser }: { reqUser: UserDocument }) {
|
||||
const { user } = useContext(UserContext);
|
||||
|
||||
return <>{user?.id === reqUser.id ? "You have" : `${reqUser.username} has`}</>;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import ProfilePicture from "components/user/ProfilePicture";
|
||||
import React from "react";
|
||||
import { Link } from "react-router-dom";
|
||||
import { PublicUserDocument } from "tachi-common";
|
||||
import { UserDocument } from "tachi-common";
|
||||
import { JustChildren, GamePT } from "types/react";
|
||||
|
||||
export default function UserIcon({
|
||||
@@ -9,7 +9,7 @@ export default function UserIcon({
|
||||
children,
|
||||
game,
|
||||
playtype,
|
||||
}: { user: PublicUserDocument } & Partial<JustChildren> & Partial<GamePT>) {
|
||||
}: { user: UserDocument } & Partial<JustChildren> & Partial<GamePT>) {
|
||||
return (
|
||||
<div className="text-center p-8">
|
||||
<ProfilePicture user={user} />
|
||||
|
||||
@@ -2,7 +2,7 @@ import { APIFetchV1 } from "util/api";
|
||||
import ProfilePicture from "components/user/ProfilePicture";
|
||||
import React, { useEffect, useState } from "react";
|
||||
import { Button, Col, Modal, Row } from "react-bootstrap";
|
||||
import { integer, PublicUserDocument } from "tachi-common";
|
||||
import { integer, UserDocument } from "tachi-common";
|
||||
import { SetState } from "types/react";
|
||||
import DebounceSearch from "../DebounceSearch";
|
||||
import Divider from "../Divider";
|
||||
@@ -17,13 +17,13 @@ export default function UserSelectModal({
|
||||
}: {
|
||||
show: boolean;
|
||||
setShow: SetState<boolean>;
|
||||
callback: (user: PublicUserDocument) => void;
|
||||
callback: (user: UserDocument) => void;
|
||||
url?: string;
|
||||
excludeSet?: Array<integer>;
|
||||
excludeMsg?: string;
|
||||
}) {
|
||||
const [search, setSearch] = useState("");
|
||||
const [users, setUsers] = useState<Array<PublicUserDocument> | null>(null);
|
||||
const [users, setUsers] = useState<Array<UserDocument> | null>(null);
|
||||
const [errMsg, setErrMsg] = useState<string | null>(null);
|
||||
|
||||
useEffect(() => {
|
||||
@@ -34,7 +34,7 @@ export default function UserSelectModal({
|
||||
const searchParams = new URLSearchParams();
|
||||
searchParams.set("search", search);
|
||||
|
||||
APIFetchV1<PublicUserDocument[]>(`${url}?${searchParams.toString()}`).then((res) => {
|
||||
APIFetchV1<UserDocument[]>(`${url}?${searchParams.toString()}`).then((res) => {
|
||||
if (res.success) {
|
||||
setErrMsg(null);
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ import {
|
||||
FormatGame,
|
||||
Game,
|
||||
Playtype,
|
||||
PublicUserDocument,
|
||||
UserDocument,
|
||||
UGPTSettings,
|
||||
UserGameStats,
|
||||
} from "tachi-common";
|
||||
@@ -19,7 +19,7 @@ export interface UGPTData {
|
||||
stats: UserGameStats;
|
||||
game: Game;
|
||||
playtype: Playtype;
|
||||
user: PublicUserDocument;
|
||||
user: UserDocument;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -60,7 +60,7 @@ export default async function fetchUGPTData(
|
||||
);
|
||||
}
|
||||
|
||||
const userRes = await APIFetchV1<PublicUserDocument>(`/users/${userID}`);
|
||||
const userRes = await APIFetchV1<UserDocument>(`/users/${userID}`);
|
||||
|
||||
if (!userRes.success) {
|
||||
throw new Error(`Failed to fetch user info for ${userID}: ${userRes.description}`);
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
import { useMemo } from "react";
|
||||
import { PublicUserDocument } from "tachi-common";
|
||||
import { UserDocument } from "tachi-common";
|
||||
import { GamePT } from "types/react";
|
||||
|
||||
export default function useUGPTBase({
|
||||
reqUser,
|
||||
game,
|
||||
playtype,
|
||||
}: { reqUser: PublicUserDocument } & GamePT) {
|
||||
}: { reqUser: UserDocument } & GamePT) {
|
||||
return useMemo(
|
||||
() => `/dashboard/users/${reqUser.username}/games/${game}/${playtype}`,
|
||||
[reqUser, game, playtype]
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
import React, { createContext, useState } from "react";
|
||||
import { PublicUserDocument } from "tachi-common";
|
||||
import { UserDocument } from "tachi-common";
|
||||
import { JustChildren, SetState } from "types/react";
|
||||
|
||||
/**
|
||||
* Contains the current user's user document.
|
||||
*/
|
||||
export const UserContext = createContext<{
|
||||
user: PublicUserDocument | null;
|
||||
setUser: SetState<PublicUserDocument | null>;
|
||||
user: UserDocument | null;
|
||||
setUser: SetState<UserDocument | null>;
|
||||
}>({ user: null, setUser: () => void 0 });
|
||||
UserContext.displayName = "UserContext";
|
||||
|
||||
export function UserContextProvider({ children }: JustChildren) {
|
||||
const [user, setUser] = useState<PublicUserDocument | null>(null);
|
||||
const [user, setUser] = useState<UserDocument | null>(null);
|
||||
|
||||
return <UserContext.Provider value={{ user, setUser }}>{children}</UserContext.Provider>;
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ import {
|
||||
integer,
|
||||
Lamps,
|
||||
PBScoreDocument,
|
||||
PublicUserDocument,
|
||||
UserDocument,
|
||||
ScoreDocument,
|
||||
SessionDocument,
|
||||
ShowcaseStatChart,
|
||||
@@ -44,7 +44,7 @@ export interface UGPTStatsReturn<I extends IDStrings = IDStrings> {
|
||||
export interface UGPTLeaderboardAdjacent {
|
||||
above: UserGameStats[];
|
||||
below: UserGameStats[];
|
||||
users: PublicUserDocument[];
|
||||
users: UserDocument[];
|
||||
thisUsersStats: UserGameStats;
|
||||
thisUsersRanking: {
|
||||
ranking: integer;
|
||||
@@ -54,7 +54,7 @@ export interface UGPTLeaderboardAdjacent {
|
||||
|
||||
export interface GPTLeaderboard {
|
||||
gameStats: UserGameStats[];
|
||||
users: PublicUserDocument[];
|
||||
users: UserDocument[];
|
||||
}
|
||||
|
||||
export type UGPTPreferenceStatsReturn =
|
||||
@@ -79,7 +79,7 @@ export interface SessionReturns<I extends IDStrings = IDStrings> {
|
||||
scores: ScoreDocument[];
|
||||
songs: SongDocument<IDStringToGame[I]>[];
|
||||
charts: ChartDocument<I>[];
|
||||
user: PublicUserDocument;
|
||||
user: UserDocument;
|
||||
}
|
||||
|
||||
export interface UGPTChartPBComposition<I extends IDStrings = IDStrings> {
|
||||
@@ -137,7 +137,7 @@ export interface GPTStatsReturn {
|
||||
|
||||
export interface RecentClassesReturn {
|
||||
classes: ClassAchievementDocument[];
|
||||
users: PublicUserDocument[];
|
||||
users: UserDocument[];
|
||||
}
|
||||
|
||||
export interface SongsReturn<I extends IDStrings = IDStrings> {
|
||||
@@ -146,26 +146,26 @@ export interface SongsReturn<I extends IDStrings = IDStrings> {
|
||||
}
|
||||
|
||||
export interface ChartPBLeaderboardReturn<I extends IDStrings = IDStrings> {
|
||||
users: PublicUserDocument[];
|
||||
users: UserDocument[];
|
||||
pbs: PBScoreDocument<I>[];
|
||||
}
|
||||
|
||||
export interface UGPTChartLeaderboardAdjacent<I extends IDStrings = IDStrings> {
|
||||
users: PublicUserDocument[];
|
||||
users: UserDocument[];
|
||||
pb: PBScoreDocument<I>;
|
||||
adjacentAbove: PBScoreDocument<I>[];
|
||||
adjacentBelow: PBScoreDocument<I>[];
|
||||
}
|
||||
|
||||
export interface ScoreLeaderboardReturns<I extends IDStrings = IDStrings> {
|
||||
users: PublicUserDocument[];
|
||||
users: UserDocument[];
|
||||
songs: SongDocument<IDStringToGame[I]>[];
|
||||
charts: ChartDocument<I>[];
|
||||
pbs: PBScoreDocument<I>[];
|
||||
}
|
||||
|
||||
export interface UserLeaderboardReturns<I extends IDStrings = IDStrings> {
|
||||
users: PublicUserDocument[];
|
||||
users: UserDocument[];
|
||||
gameStats: UserGameStats<I>[];
|
||||
}
|
||||
|
||||
@@ -188,7 +188,7 @@ export interface ServerStatus {
|
||||
}
|
||||
|
||||
export interface ChallengeSubsReturn {
|
||||
rivals: Array<PublicUserDocument>;
|
||||
rivals: Array<UserDocument>;
|
||||
pbs: Array<PBScoreDocument>;
|
||||
challengeSubs: Array<ChallengeSubscriptionDocument>;
|
||||
songs: Array<SongDocument>;
|
||||
@@ -196,7 +196,7 @@ export interface ChallengeSubsReturn {
|
||||
}
|
||||
|
||||
export interface ChartRivalsReturn {
|
||||
rivals: Array<PublicUserDocument>;
|
||||
rivals: Array<UserDocument>;
|
||||
pbs: Array<PBScoreDocument>;
|
||||
}
|
||||
|
||||
@@ -206,15 +206,15 @@ export interface ImportIDReturn {
|
||||
charts: ChartDocument[];
|
||||
sessions: SessionDocument[];
|
||||
import: ImportDocument;
|
||||
user: PublicUserDocument;
|
||||
user: UserDocument;
|
||||
}
|
||||
|
||||
export interface FailedImportsReturn {
|
||||
failedImports: Array<ImportTrackerFailed>;
|
||||
users: Array<PublicUserDocument>;
|
||||
users: Array<UserDocument>;
|
||||
}
|
||||
|
||||
export interface ImportsReturn {
|
||||
imports: Array<ImportDocument>;
|
||||
users: Array<PublicUserDocument>;
|
||||
users: Array<UserDocument>;
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ import {
|
||||
ImportTrackerFailed,
|
||||
integer,
|
||||
PBScoreDocument,
|
||||
PublicUserDocument,
|
||||
UserDocument,
|
||||
ScoreDocument,
|
||||
SongDocument,
|
||||
UserGameStats,
|
||||
@@ -17,7 +17,7 @@ export type PBDataset<I extends IDStrings = IDStrings> = (PBScoreDocument<I> & {
|
||||
chart: ChartDocument<I>;
|
||||
song: SongDocument<IDStringToGame[I]>;
|
||||
index: integer;
|
||||
user?: PublicUserDocument;
|
||||
user?: UserDocument;
|
||||
};
|
||||
__playcount?: integer;
|
||||
})[];
|
||||
@@ -27,7 +27,7 @@ export type ScoreDataset<I extends IDStrings = IDStrings> = (ScoreDocument<I> &
|
||||
chart: ChartDocument<I>;
|
||||
song: SongDocument<IDStringToGame[I]>;
|
||||
index: integer;
|
||||
user: PublicUserDocument;
|
||||
user: UserDocument;
|
||||
};
|
||||
})[];
|
||||
|
||||
@@ -35,24 +35,24 @@ export type FolderDataset<I extends IDStrings = IDStrings> = (ChartDocument<I> &
|
||||
__related: {
|
||||
pb: PBScoreDocument<I> | null;
|
||||
song: SongDocument<IDStringToGame[I]>;
|
||||
user: PublicUserDocument;
|
||||
user: UserDocument;
|
||||
};
|
||||
})[];
|
||||
|
||||
export type ChartLeaderboardDataset<I extends IDStrings = IDStrings> = (PBScoreDocument<I> & {
|
||||
__related: {
|
||||
user: PublicUserDocument;
|
||||
user: UserDocument;
|
||||
};
|
||||
})[];
|
||||
|
||||
export type UGSDataset<I extends IDStrings = IDStrings> = (UserGameStats<I> & {
|
||||
__related: {
|
||||
user: PublicUserDocument;
|
||||
user: UserDocument;
|
||||
index: integer;
|
||||
};
|
||||
})[];
|
||||
|
||||
export type RivalChartDataset<I extends IDStrings = IDStrings> = (PublicUserDocument & {
|
||||
export type RivalChartDataset<I extends IDStrings = IDStrings> = (UserDocument & {
|
||||
__related: {
|
||||
pb: PBScoreDocument<I> | null;
|
||||
index: number;
|
||||
@@ -69,7 +69,7 @@ export type ComparePBsDataset<I extends IDStrings = IDStrings> = Array<{
|
||||
export type ImportDataset = Array<
|
||||
ImportDocument & {
|
||||
__related: {
|
||||
user: PublicUserDocument;
|
||||
user: UserDocument;
|
||||
};
|
||||
}
|
||||
>;
|
||||
@@ -77,7 +77,7 @@ export type ImportDataset = Array<
|
||||
export type FailedImportDataset = Array<
|
||||
ImportTrackerFailed & {
|
||||
__related: {
|
||||
user: PublicUserDocument;
|
||||
user: UserDocument;
|
||||
};
|
||||
}
|
||||
>;
|
||||
|
||||
@@ -4,7 +4,7 @@ import {
|
||||
GoalDocument,
|
||||
IDStrings,
|
||||
integer,
|
||||
PublicUserDocument,
|
||||
UserDocument,
|
||||
ScoreDocument,
|
||||
SessionScoreInfo,
|
||||
SongDocument,
|
||||
@@ -24,8 +24,8 @@ export function CreateSongMap<G extends Game = Game>(songs: SongDocument<G>[]) {
|
||||
return songMap;
|
||||
}
|
||||
|
||||
export function CreateUserMap(users: PublicUserDocument[]) {
|
||||
const userMap = new Map<integer, PublicUserDocument>();
|
||||
export function CreateUserMap(users: UserDocument[]) {
|
||||
const userMap = new Map<integer, UserDocument>();
|
||||
|
||||
for (const user of users) {
|
||||
userMap.set(user.id, user);
|
||||
|
||||
+1
-1
@@ -670,7 +670,7 @@ export enum UserAuthLevels {
|
||||
ADMIN = 3,
|
||||
}
|
||||
|
||||
export interface PublicUserDocument extends MongoDBDocument {
|
||||
export interface UserDocument extends MongoDBDocument {
|
||||
username: string;
|
||||
usernameLowercase: string;
|
||||
id: integer;
|
||||
|
||||
Vendored
+2
-2
@@ -34,7 +34,7 @@ import type {
|
||||
NotificationDocument,
|
||||
OrphanChart,
|
||||
PBScoreDocument,
|
||||
PublicUserDocument,
|
||||
UserDocument,
|
||||
RecentlyViewedFolderDocument,
|
||||
ScoreDocument,
|
||||
SessionDocument,
|
||||
@@ -145,7 +145,7 @@ const db = {
|
||||
"goal-subs": monkDB.get<GoalSubscriptionDocument>("goal-subs"),
|
||||
quests: monkDB.get<QuestDocument>("quests"),
|
||||
"quest-subs": monkDB.get<QuestSubscriptionDocument>("quest-subs"),
|
||||
users: monkDB.get<PublicUserDocument>("users"),
|
||||
users: monkDB.get<UserDocument>("users"),
|
||||
imports: monkDB.get<ImportDocument>("imports"),
|
||||
"import-timings": monkDB.get<ImportTimingsDocument>("import-timings"),
|
||||
sessions: monkDB.get<SessionDocument>("sessions"),
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { ONE_MONTH } from "lib/constants/time";
|
||||
import CreateLogCtx from "lib/logger/logger";
|
||||
import { ServerConfig } from "lib/setup/config";
|
||||
import type { PublicUserDocument } from "tachi-common";
|
||||
import type { UserDocument } from "tachi-common";
|
||||
|
||||
const logger = CreateLogCtx(__filename);
|
||||
|
||||
@@ -12,7 +12,7 @@ const logger = CreateLogCtx(__filename);
|
||||
* Users get those N additional invites every month since they join.
|
||||
* This is capped at INVITE_CAP, which defaults to 100.
|
||||
*/
|
||||
export function GetTotalAllowedInvites(user: PublicUserDocument) {
|
||||
export function GetTotalAllowedInvites(user: UserDocument) {
|
||||
if (!ServerConfig.INVITE_CODE_CONFIG) {
|
||||
logger.warn(
|
||||
`No INVITE_CODE_CONFIG set, but tried to get total allowed invites? Returning 0.`
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { SendNotification } from "./notifications";
|
||||
import db from "external/mongo/db";
|
||||
import { FormatGame } from "tachi-common";
|
||||
import type { Game, integer, Playtype, PublicUserDocument } from "tachi-common";
|
||||
import type { Game, integer, Playtype, UserDocument } from "tachi-common";
|
||||
|
||||
/**
|
||||
* A utility wrapper for sending the RIVALED_BY notification.
|
||||
@@ -13,7 +13,7 @@ import type { Game, integer, Playtype, PublicUserDocument } from "tachi-common";
|
||||
*/
|
||||
export async function SendSetRivalNotification(
|
||||
toUserID: integer,
|
||||
fromUser: PublicUserDocument,
|
||||
fromUser: UserDocument,
|
||||
game: Game,
|
||||
playtype: Playtype
|
||||
) {
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import { rootLogger } from "lib/logger/logger";
|
||||
import { FormatUserDoc } from "utils/user";
|
||||
import type { KtLogger } from "lib/logger/logger";
|
||||
import type { ImportTypes, PublicUserDocument } from "tachi-common";
|
||||
import type { ImportTypes, UserDocument } from "tachi-common";
|
||||
|
||||
export function CreateScoreLogger(
|
||||
user: PublicUserDocument,
|
||||
user: UserDocument,
|
||||
importID: string,
|
||||
importType: ImportTypes
|
||||
): KtLogger {
|
||||
|
||||
@@ -26,7 +26,7 @@ import type {
|
||||
ImportTypes,
|
||||
integer,
|
||||
Playtype,
|
||||
PublicUserDocument,
|
||||
UserDocument,
|
||||
} from "tachi-common";
|
||||
|
||||
/**
|
||||
@@ -257,7 +257,7 @@ export default async function ScoreImportMain<D, C>(
|
||||
*/
|
||||
export async function HandlePostImportSteps(
|
||||
importInfo: Array<ImportProcessingInfo>,
|
||||
user: PublicUserDocument,
|
||||
user: UserDocument,
|
||||
importType: ImportTypes,
|
||||
game: Game,
|
||||
classHandler: ClassHandler | null,
|
||||
|
||||
@@ -5,10 +5,10 @@ import db from "external/mongo/db";
|
||||
import t from "tap";
|
||||
import ResetDBState from "test-utils/resets";
|
||||
import { TestingIIDXSPScore, TestingIIDXSPScorePB } from "test-utils/test-data";
|
||||
import type { PublicUserDocument, ScoreDocument, SessionDocument } from "tachi-common";
|
||||
import type { UserDocument, ScoreDocument, SessionDocument } from "tachi-common";
|
||||
|
||||
const logger = CreateScoreLogger(
|
||||
{ username: "test_zkldi", id: 1 } as PublicUserDocument,
|
||||
{ username: "test_zkldi", id: 1 } as UserDocument,
|
||||
"foo",
|
||||
"ir/direct-manual"
|
||||
);
|
||||
|
||||
@@ -12,7 +12,7 @@ import type {
|
||||
Game,
|
||||
integer,
|
||||
Playtype,
|
||||
PublicUserDocument,
|
||||
UserDocument,
|
||||
SessionDocument,
|
||||
SongDocument,
|
||||
} from "tachi-common";
|
||||
@@ -134,7 +134,7 @@ export function SearchSessions(
|
||||
export function SearchUsersRegExp(search: string, matchOnline = false) {
|
||||
const regexEsc = EscapeStringRegexp(search.toLowerCase());
|
||||
|
||||
const matchQuery: FilterQuery<PublicUserDocument> = {
|
||||
const matchQuery: FilterQuery<UserDocument> = {
|
||||
usernameLowercase: { $regex: new RegExp(regexEsc, "u") },
|
||||
};
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ import nodeFetch from "utils/fetch";
|
||||
import { Random20Hex } from "utils/misc";
|
||||
import { CreateURLWithParams } from "utils/url";
|
||||
import { FormatUserDoc } from "utils/user";
|
||||
import type { integer, PublicUserDocument, UserSettings } from "tachi-common";
|
||||
import type { integer, UserDocument, UserSettings } from "tachi-common";
|
||||
import type { PrivateUserInfoDocument } from "utils/types";
|
||||
|
||||
const logger = CreateLogCtx(__filename);
|
||||
@@ -43,7 +43,7 @@ export function ReinstateInvite(code: string) {
|
||||
);
|
||||
}
|
||||
|
||||
export async function AddNewInvite(user: PublicUserDocument) {
|
||||
export async function AddNewInvite(user: UserDocument) {
|
||||
const code = Random20Hex();
|
||||
|
||||
const result = await db.invites.insert({
|
||||
@@ -82,7 +82,7 @@ export async function AddNewUser(
|
||||
|
||||
logger.verbose(`Hashed password for ${username}.`);
|
||||
|
||||
const userDoc: PublicUserDocument = {
|
||||
const userDoc: UserDocument = {
|
||||
id: userID,
|
||||
username,
|
||||
usernameLowercase: username.toLowerCase(),
|
||||
@@ -169,7 +169,7 @@ export async function ValidateCaptcha(
|
||||
|
||||
export function MountAuthCookie(
|
||||
req: Express.Request,
|
||||
user: PublicUserDocument,
|
||||
user: UserDocument,
|
||||
settings: UserSettings
|
||||
) {
|
||||
req.session.tachi = {
|
||||
|
||||
+2
-2
@@ -4,7 +4,7 @@ import t from "tap";
|
||||
import mockApi from "test-utils/mock-api";
|
||||
import ResetDBState from "test-utils/resets";
|
||||
import { Testing511SPA, TestingIIDXSPScorePB } from "test-utils/test-data";
|
||||
import type { PBScoreDocument, PublicUserDocument } from "tachi-common";
|
||||
import type { PBScoreDocument, UserDocument } from "tachi-common";
|
||||
|
||||
t.test("GET /api/v1/games/:game/:playtype/charts/:chartID", (t) => {
|
||||
t.beforeEach(ResetDBState);
|
||||
@@ -54,7 +54,7 @@ t.test("GET /api/v1/games/:game/:playtype/charts/:chartID/pbs", (t) => {
|
||||
id: 2,
|
||||
username: "foo",
|
||||
usernameLowercase: "foo",
|
||||
} as PublicUserDocument);
|
||||
} as UserDocument);
|
||||
|
||||
const res = await mockApi.get(`/api/v1/games/iidx/SP/charts/${Testing511SPA.chartID}/pbs`);
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ import { mkFakeGameStats, mkFakeUser } from "test-utils/misc";
|
||||
import mockApi from "test-utils/mock-api";
|
||||
import ResetDBState from "test-utils/resets";
|
||||
import { FakeOtherUser } from "test-utils/test-data";
|
||||
import type { PublicUserDocument, UserGameStats } from "tachi-common";
|
||||
import type { UserDocument, UserGameStats } from "tachi-common";
|
||||
|
||||
t.test("GET /api/v1/games/:game/:playtype", (t) => {
|
||||
t.test("Should return information about the game:playtype.", async (t) => {
|
||||
@@ -95,7 +95,7 @@ t.test("GET /api/v1/games/:game/:playtype/leaderboard", (t) => {
|
||||
username: "foo",
|
||||
usernameLowercase: "foo",
|
||||
id: 3,
|
||||
}) as PublicUserDocument,
|
||||
}) as UserDocument,
|
||||
]);
|
||||
|
||||
const res = await mockApi.get("/api/v1/games/iidx/SP/leaderboard?alg=BPI");
|
||||
|
||||
@@ -11,7 +11,7 @@ import { RequireBokutachi } from "server/middleware/type-require";
|
||||
import { IsString } from "utils/misc";
|
||||
import { GetAllUserRivals, GetUserPlayedGPTs } from "utils/user";
|
||||
import type { FilterQuery } from "mongodb";
|
||||
import type { FolderDocument, Game, integer, PublicUserDocument, SongDocument } from "tachi-common";
|
||||
import type { FolderDocument, Game, integer, UserDocument, SongDocument } from "tachi-common";
|
||||
|
||||
const router: Router = Router({ mergeParams: true });
|
||||
|
||||
@@ -32,7 +32,7 @@ router.get("/", async (req, res) => {
|
||||
|
||||
const userID = req[SYMBOL_TACHI_API_AUTH].userID;
|
||||
|
||||
let filter: FilterQuery<FolderDocument & PublicUserDocument & SongDocument> = {};
|
||||
let filter: FilterQuery<FolderDocument & UserDocument & SongDocument> = {};
|
||||
let relevantGames: Array<Game> = TachiConfig.GAMES;
|
||||
|
||||
if (userID !== null) {
|
||||
@@ -64,7 +64,7 @@ router.get("/", async (req, res) => {
|
||||
);
|
||||
|
||||
// @ts-expect-error Handled below -- the field is added by the below for loop.
|
||||
const usersWithRivalTag: Array<PublicUserDocument & { __isRival: boolean }> = users;
|
||||
const usersWithRivalTag: Array<UserDocument & { __isRival: boolean }> = users;
|
||||
|
||||
let rivals: Array<integer> = [];
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ import t from "tap";
|
||||
import { CreateFakeAuthCookie } from "test-utils/fake-auth";
|
||||
import mockApi from "test-utils/mock-api";
|
||||
import ResetDBState from "test-utils/resets";
|
||||
import type { PublicUserDocument } from "tachi-common";
|
||||
import type { UserDocument } from "tachi-common";
|
||||
|
||||
t.test("GET /api/v1/users/:userID/api-tokens", async (t) => {
|
||||
t.beforeEach(ResetDBState);
|
||||
@@ -75,7 +75,7 @@ t.test("GET /api/v1/users/:userID/api-tokens", async (t) => {
|
||||
username: "test",
|
||||
usernameLowercase: "test",
|
||||
id: 2,
|
||||
} as PublicUserDocument);
|
||||
} as UserDocument);
|
||||
|
||||
const res2 = await mockApi.get("/api/v1/users/2/api-tokens").set("Cookie", cookie);
|
||||
|
||||
|
||||
+3
-3
@@ -5,7 +5,7 @@ import { mkFakeGameSettings, mkFakeUser } from "test-utils/misc";
|
||||
import mockApi from "test-utils/mock-api";
|
||||
import ResetDBState from "test-utils/resets";
|
||||
import { FakeOtherUser } from "test-utils/test-data";
|
||||
import type { PublicUserDocument } from "tachi-common";
|
||||
import type { UserDocument } from "tachi-common";
|
||||
|
||||
const SetupRivals = async () => {
|
||||
await db.users.insert([FakeOtherUser, mkFakeUser(3), mkFakeUser(4)]);
|
||||
@@ -36,7 +36,7 @@ t.test("GET /api/v1/users/:userID/games/:game/:playtype/rivals", (t) => {
|
||||
t.equal(res.statusCode, 200);
|
||||
|
||||
t.strictSame(
|
||||
res.body.body.map((e: PublicUserDocument) => e.id),
|
||||
res.body.body.map((e: UserDocument) => e.id),
|
||||
[2, 3],
|
||||
"Should have the users rivals and no more."
|
||||
);
|
||||
@@ -178,7 +178,7 @@ t.test("GET /api/v1/users/:userID/games/:game/:playtype/rivals/challengers", (t)
|
||||
t.equal(res.statusCode, 200);
|
||||
|
||||
t.hasStrict(
|
||||
res.body.body.map((e: PublicUserDocument) => e.id),
|
||||
res.body.body.map((e: UserDocument) => e.id),
|
||||
[3, 4, 5]
|
||||
);
|
||||
|
||||
|
||||
+2
-2
@@ -6,7 +6,7 @@ import mockApi from "test-utils/mock-api";
|
||||
import ResetDBState from "test-utils/resets";
|
||||
import { Testing511SPA, TestingIIDXFolderSP10, TestingIIDXSPScorePB } from "test-utils/test-data";
|
||||
import { CreateFolderChartLookup } from "utils/folder";
|
||||
import type { ChartDocument, PublicUserDocument } from "tachi-common";
|
||||
import type { ChartDocument, UserDocument } from "tachi-common";
|
||||
|
||||
const SetFolders = async () => {
|
||||
await db.folders.insert(TestingIIDXFolderSP10);
|
||||
@@ -112,7 +112,7 @@ t.test("GET /api/v1/users/:userID/games/:game/:playtype/showcase", (t) => {
|
||||
username: "test_acc",
|
||||
usernameLowercase: "test_acc",
|
||||
id: 2,
|
||||
} as PublicUserDocument);
|
||||
} as UserDocument);
|
||||
|
||||
const res = await mockApi.get("/api/v1/users/1/games/iidx/SP/showcase?projectUser=2");
|
||||
|
||||
|
||||
+3
-3
@@ -9,7 +9,7 @@ import {
|
||||
TestingIIDXSPQuest,
|
||||
TestingIIDXSPQuestSub,
|
||||
} from "test-utils/test-data";
|
||||
import type { PublicUserDocument, UserGameStats } from "tachi-common";
|
||||
import type { UserDocument, UserGameStats } from "tachi-common";
|
||||
|
||||
t.test("GET /api/v1/users/:userID/games/:game/:playtype/targets/quests", (t) => {
|
||||
t.beforeEach(ResetDBState);
|
||||
@@ -158,7 +158,7 @@ t.test("PUT /api/v1/users/:userID/games/:game/:playtype/targets/quests/:questID"
|
||||
id: 2,
|
||||
username: "fake_person",
|
||||
usernameLowercase: "fake_person",
|
||||
} as PublicUserDocument);
|
||||
} as UserDocument);
|
||||
|
||||
await db["game-stats"].insert({
|
||||
game: "iidx",
|
||||
@@ -206,7 +206,7 @@ t.test("DELETE /api/v1/users/:userID/games/:game/:playtype/targets/quests/:quest
|
||||
id: 2,
|
||||
username: "fake_person",
|
||||
usernameLowercase: "fake_person",
|
||||
} as PublicUserDocument);
|
||||
} as UserDocument);
|
||||
|
||||
await db["game-stats"].insert({
|
||||
game: "iidx",
|
||||
|
||||
@@ -3,7 +3,7 @@ import t from "tap";
|
||||
import { CreateFakeAuthCookie } from "test-utils/fake-auth";
|
||||
import mockApi from "test-utils/mock-api";
|
||||
import ResetDBState from "test-utils/resets";
|
||||
import type { PublicUserDocument } from "tachi-common";
|
||||
import type { UserDocument } from "tachi-common";
|
||||
|
||||
t.test("GET /api/v1/users/:userID/integrations/fervidex/settings", async (t) => {
|
||||
t.beforeEach(ResetDBState);
|
||||
@@ -58,7 +58,7 @@ t.test("GET /api/v1/users/:userID/integrations/fervidex/settings", async (t) =>
|
||||
id: 2,
|
||||
username: "foo",
|
||||
usernameLowercase: "foo",
|
||||
} as PublicUserDocument);
|
||||
} as UserDocument);
|
||||
|
||||
const res3 = await mockApi
|
||||
.get("/api/v1/users/2/integrations/fervidex/settings")
|
||||
|
||||
+2
-2
@@ -3,7 +3,7 @@ import t from "tap";
|
||||
import { CreateFakeAuthCookie } from "test-utils/fake-auth";
|
||||
import mockApi from "test-utils/mock-api";
|
||||
import ResetDBState from "test-utils/resets";
|
||||
import type { PublicUserDocument } from "tachi-common";
|
||||
import type { UserDocument } from "tachi-common";
|
||||
|
||||
t.test("GET /api/v1/users/:userID/integrations/kshook-sv6c/settings", async (t) => {
|
||||
t.beforeEach(ResetDBState);
|
||||
@@ -55,7 +55,7 @@ t.test("GET /api/v1/users/:userID/integrations/kshook-sv6c/settings", async (t)
|
||||
id: 2,
|
||||
username: "foo",
|
||||
usernameLowercase: "foo",
|
||||
} as PublicUserDocument);
|
||||
} as UserDocument);
|
||||
|
||||
const res3 = await mockApi
|
||||
.get("/api/v1/users/2/integrations/kshook-sv6c/settings")
|
||||
|
||||
@@ -5,7 +5,7 @@ import t from "tap";
|
||||
import { CreateFakeAuthCookie } from "test-utils/fake-auth";
|
||||
import mockApi from "test-utils/mock-api";
|
||||
import ResetDBState from "test-utils/resets";
|
||||
import type { InviteCodeDocument, PublicUserDocument } from "tachi-common";
|
||||
import type { InviteCodeDocument, UserDocument } from "tachi-common";
|
||||
|
||||
t.test("GET /api/v1/users/:userID/invites", async (t) => {
|
||||
t.beforeEach(ResetDBState);
|
||||
@@ -17,7 +17,7 @@ t.test("GET /api/v1/users/:userID/invites", async (t) => {
|
||||
id: 2,
|
||||
username: "other_dude",
|
||||
usernameLowercase: "other_dude",
|
||||
} as PublicUserDocument);
|
||||
} as UserDocument);
|
||||
|
||||
const res = await mockApi.get("/api/v1/users/1/invites").set("Cookie", cookie);
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ import t from "tap";
|
||||
import { CreateFakeAuthCookie } from "test-utils/fake-auth";
|
||||
import mockApi from "test-utils/mock-api";
|
||||
import ResetDBState from "test-utils/resets";
|
||||
import type { PublicUserDocument } from "tachi-common";
|
||||
import type { UserDocument } from "tachi-common";
|
||||
|
||||
t.test("GET /api/v1/users/:userID/settings", (t) => {
|
||||
t.beforeEach(ResetDBState);
|
||||
@@ -125,7 +125,7 @@ t.test("PATCH /api/v1/users/:userID/settings", async (t) => {
|
||||
id: 2,
|
||||
username: "something_else",
|
||||
usernameLowercase: "something_else",
|
||||
}) as PublicUserDocument
|
||||
}) as UserDocument
|
||||
);
|
||||
|
||||
const res = await mockApi
|
||||
|
||||
@@ -2,7 +2,7 @@ import db from "external/mongo/db";
|
||||
import t from "tap";
|
||||
import mockApi from "test-utils/mock-api";
|
||||
import ResetDBState from "test-utils/resets";
|
||||
import type { PublicUserDocument } from "tachi-common";
|
||||
import type { UserDocument } from "tachi-common";
|
||||
|
||||
t.test("GET /api/v1/users", (t) => {
|
||||
t.beforeEach(ResetDBState);
|
||||
@@ -43,7 +43,7 @@ t.test("GET /api/v1/users", (t) => {
|
||||
usernameLowercase: "online_dude",
|
||||
lastSeen: Date.now(),
|
||||
id: 2,
|
||||
} as PublicUserDocument);
|
||||
} as UserDocument);
|
||||
|
||||
const res2 = await mockApi.get("/api/v1/users?online=true");
|
||||
|
||||
@@ -59,13 +59,13 @@ t.test("GET /api/v1/users", (t) => {
|
||||
usernameLowercase: "online_dude",
|
||||
lastSeen: Date.now(),
|
||||
id: 2,
|
||||
} as PublicUserDocument);
|
||||
} as UserDocument);
|
||||
|
||||
const res = await mockApi.get("/api/v1/users");
|
||||
|
||||
t.equal(res.body.body.length, 2);
|
||||
t.strictSame(
|
||||
res.body.body.map((e: PublicUserDocument) => e.usernameLowercase),
|
||||
res.body.body.map((e: UserDocument) => e.usernameLowercase),
|
||||
["online_dude", "test_zkldi"]
|
||||
);
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ import { SYMBOL_TACHI_API_AUTH } from "lib/constants/tachi";
|
||||
import CreateLogCtx from "lib/logger/logger";
|
||||
import { AssignToReqTachiData, GetTachiData } from "utils/req-tachi-data";
|
||||
import type { RequestHandler } from "express";
|
||||
import type { ChartDocument, integer, PBScoreDocument, PublicUserDocument } from "tachi-common";
|
||||
import type { ChartDocument, integer, PBScoreDocument, UserDocument } from "tachi-common";
|
||||
|
||||
const router: Router = Router({ mergeParams: true });
|
||||
|
||||
@@ -64,7 +64,7 @@ router.get("/scores", async (req, res) => {
|
||||
},
|
||||
}
|
||||
);
|
||||
const userMap = new Map<integer, PublicUserDocument>();
|
||||
const userMap = new Map<integer, UserDocument>();
|
||||
|
||||
for (const user of userDocs) {
|
||||
userMap.set(user.id, user);
|
||||
|
||||
@@ -4,7 +4,7 @@ import t from "tap";
|
||||
import mockApi from "test-utils/mock-api";
|
||||
import ResetDBState from "test-utils/resets";
|
||||
import { MockBeatorajaBMSScore, MockBeatorajaPMSScore } from "test-utils/test-data";
|
||||
import type { PublicUserDocument } from "tachi-common";
|
||||
import type { UserDocument } from "tachi-common";
|
||||
|
||||
t.test("POST /ir/beatoraja/submit-score", (t) => {
|
||||
t.beforeEach(ResetDBState);
|
||||
@@ -272,7 +272,7 @@ t.test("POST /ir/beatoraja/submit-score", (t) => {
|
||||
username: "bar",
|
||||
usernameLowercase: "bar",
|
||||
},
|
||||
] as Array<PublicUserDocument>);
|
||||
] as Array<UserDocument>);
|
||||
|
||||
const res = await mockApi
|
||||
.post("/ir/beatoraja/submit-score")
|
||||
|
||||
@@ -5,7 +5,7 @@ import t from "tap";
|
||||
import mockApi from "test-utils/mock-api";
|
||||
import ResetDBState, { ResetCDN } from "test-utils/resets";
|
||||
import { GetKTDataBuffer } from "test-utils/test-data";
|
||||
import type { PBScoreDocument, PublicUserDocument, ScoreDocument } from "tachi-common";
|
||||
import type { PBScoreDocument, UserDocument, ScoreDocument } from "tachi-common";
|
||||
|
||||
async function InsertFakeUSCAuth() {
|
||||
await db["api-tokens"].insert({
|
||||
@@ -315,7 +315,7 @@ t.test("GET /charts/:chartHash/leaderboard", (t) => {
|
||||
id: 2,
|
||||
username: "not_zkldi",
|
||||
usernameLowercase: "not_zkldi",
|
||||
} as PublicUserDocument);
|
||||
} as UserDocument);
|
||||
|
||||
await db.scores.insert([
|
||||
{
|
||||
@@ -667,7 +667,7 @@ t.test("POST /scores", (t) => {
|
||||
username: "bar",
|
||||
usernameLowercase: "bar",
|
||||
},
|
||||
] as Array<PublicUserDocument>);
|
||||
] as Array<UserDocument>);
|
||||
|
||||
const res = await mockApi
|
||||
.post("/ir/usc/Controller/scores")
|
||||
@@ -781,7 +781,7 @@ t.test("POST /scores", (t) => {
|
||||
username: "baz",
|
||||
usernameLowercase: "baz",
|
||||
},
|
||||
] as Array<PublicUserDocument>);
|
||||
] as Array<UserDocument>);
|
||||
|
||||
const res = await mockApi
|
||||
.post("/ir/usc/Controller/scores")
|
||||
|
||||
@@ -6,7 +6,7 @@ import ResetDBState from "test-utils/resets";
|
||||
import type {
|
||||
ChartDocument,
|
||||
PBScoreDocument,
|
||||
PublicUserDocument,
|
||||
UserDocument,
|
||||
ScoreDocument,
|
||||
} from "tachi-common";
|
||||
|
||||
@@ -241,7 +241,7 @@ const mockUserDocs = [2, 3, 4, 5, 6, 7, 8, 9, 10].map((e) => ({
|
||||
id: e,
|
||||
username: e.toString(),
|
||||
usernameLowercase: e.toString(),
|
||||
})) as Array<PublicUserDocument>;
|
||||
})) as Array<UserDocument>;
|
||||
|
||||
t.test("#CreatePOSTScoresResponseBody", async (t) => {
|
||||
t.beforeEach(ResetDBState);
|
||||
|
||||
@@ -23,7 +23,7 @@ import type {
|
||||
NotificationDocument,
|
||||
PBScoreDocument,
|
||||
Playtype,
|
||||
PublicUserDocument,
|
||||
UserDocument,
|
||||
ScoreDocument,
|
||||
UGPTSettings,
|
||||
UserGameStats,
|
||||
@@ -58,7 +58,7 @@ export function dmf<T extends object>(base: T, modifant: Partial<T>): T {
|
||||
*
|
||||
* @param userID - The userID this fake user should have.
|
||||
*/
|
||||
export function mkFakeUser(userID: integer, modifant: Partial<PublicUserDocument> = {}) {
|
||||
export function mkFakeUser(userID: integer, modifant: Partial<UserDocument> = {}) {
|
||||
return dmf(FakeOtherUser, {
|
||||
id: userID,
|
||||
username: `user${userID}`,
|
||||
|
||||
@@ -31,7 +31,7 @@ import type {
|
||||
QuestSubscriptionDocument,
|
||||
NotificationDocument,
|
||||
PBScoreDocument,
|
||||
PublicUserDocument,
|
||||
UserDocument,
|
||||
ScoreDocument,
|
||||
SongDocument,
|
||||
UGPTSettings,
|
||||
@@ -798,7 +798,7 @@ export const uscScore: USCClientScore = {
|
||||
},
|
||||
};
|
||||
|
||||
export const FakeOtherUser: PublicUserDocument = {
|
||||
export const FakeOtherUser: UserDocument = {
|
||||
id: 2,
|
||||
username: "other_user",
|
||||
about: "",
|
||||
|
||||
@@ -11,7 +11,7 @@ import { TachiConfig } from "lib/setup/config";
|
||||
import { GetGameConfig } from "tachi-common";
|
||||
import { EfficientDBIterate } from "utils/efficient-db-iterate";
|
||||
import { FormatUserDoc } from "utils/user";
|
||||
import type { Game, integer, Playtype, PublicUserDocument } from "tachi-common";
|
||||
import type { Game, integer, Playtype, UserDocument } from "tachi-common";
|
||||
|
||||
const logger = CreateLogCtx(__filename);
|
||||
|
||||
@@ -84,7 +84,7 @@ export async function RecalcAllScores(filter = {}) {
|
||||
}
|
||||
|
||||
export async function UpdateAllPBs(userIDs?: Array<integer>, filter = {}) {
|
||||
let allUsers: Array<PublicUserDocument>;
|
||||
let allUsers: Array<UserDocument>;
|
||||
|
||||
if (!userIDs) {
|
||||
allUsers = await db.users.find({});
|
||||
|
||||
@@ -4,7 +4,7 @@ import type {
|
||||
SessionDocument,
|
||||
ScoreDocument,
|
||||
ChartDocument,
|
||||
PublicUserDocument,
|
||||
UserDocument,
|
||||
UserGameStats,
|
||||
Game,
|
||||
Playtype,
|
||||
@@ -41,7 +41,7 @@ declare module "express-serve-static-core" {
|
||||
}
|
||||
|
||||
export interface TachiSessionData {
|
||||
user: PublicUserDocument;
|
||||
user: UserDocument;
|
||||
settings: UserSettings;
|
||||
}
|
||||
|
||||
@@ -71,7 +71,7 @@ export interface TachiRequestData {
|
||||
|
||||
beatorajaChartDoc?: ChartDocument<"bms:7K" | "bms:14K" | "pms:Controller" | "pms:Keyboard">;
|
||||
|
||||
requestedUser?: PublicUserDocument;
|
||||
requestedUser?: UserDocument;
|
||||
requestedUserGameStats?: UserGameStats;
|
||||
game?: Game;
|
||||
playtype?: Playtype;
|
||||
|
||||
@@ -4,7 +4,7 @@ import { DatabaseSchemas } from "external/mongo/schemas";
|
||||
import t from "tap";
|
||||
import { mkFakeUser } from "test-utils/misc";
|
||||
import ResetDBState from "test-utils/resets";
|
||||
import type { PublicUserDocument } from "tachi-common";
|
||||
import type { UserDocument } from "tachi-common";
|
||||
|
||||
t.test("#GetUserCaseInsensitive", (t) => {
|
||||
t.beforeEach(ResetDBState);
|
||||
@@ -100,7 +100,7 @@ t.test("#GetUsersWithIDs", (t) => {
|
||||
|
||||
t.test("#FormatUserDoc", (t) => {
|
||||
t.equal(
|
||||
FormatUserDoc({ username: "zkldi", id: 123 } as PublicUserDocument),
|
||||
FormatUserDoc({ username: "zkldi", id: 123 } as UserDocument),
|
||||
"zkldi (#123)",
|
||||
"Should format a user document into username #id format."
|
||||
);
|
||||
|
||||
@@ -9,7 +9,7 @@ import type {
|
||||
IDStrings,
|
||||
integer,
|
||||
Playtype,
|
||||
PublicUserDocument,
|
||||
UserDocument,
|
||||
UGSRatingsLookup,
|
||||
UserGameStats,
|
||||
} from "tachi-common";
|
||||
@@ -43,7 +43,7 @@ export async function GetUsernameFromUserID(userID: integer): Promise<string> {
|
||||
*/
|
||||
export function GetUserCaseInsensitive(
|
||||
username: string
|
||||
): Promise<FindOneResult<PublicUserDocument>> {
|
||||
): Promise<FindOneResult<UserDocument>> {
|
||||
return db.users.findOne({
|
||||
usernameLowercase: username.toLowerCase(),
|
||||
});
|
||||
@@ -62,7 +62,7 @@ export function GetUserPrivateInfo(userID: integer) {
|
||||
/**
|
||||
* Gets a user from their userID.
|
||||
*/
|
||||
export function GetUserWithID(userID: integer): Promise<FindOneResult<PublicUserDocument>> {
|
||||
export function GetUserWithID(userID: integer): Promise<FindOneResult<UserDocument>> {
|
||||
return db.users.findOne({
|
||||
id: userID,
|
||||
});
|
||||
@@ -102,7 +102,7 @@ export async function GetUsersWithIDs(userIDs: Array<integer>) {
|
||||
* If the user document is not found, a severe error is logged, and this
|
||||
* function throws.
|
||||
*/
|
||||
export async function GetUserWithIDGuaranteed(userID: integer): Promise<PublicUserDocument> {
|
||||
export async function GetUserWithIDGuaranteed(userID: integer): Promise<UserDocument> {
|
||||
const userDoc = await GetUserWithID(userID);
|
||||
|
||||
if (!userDoc) {
|
||||
@@ -135,7 +135,7 @@ export function ResolveUser(usernameOrID: string) {
|
||||
/**
|
||||
* Returns a formatted string indicating the user. This is used for logging.
|
||||
*/
|
||||
export function FormatUserDoc(userdoc: PublicUserDocument) {
|
||||
export function FormatUserDoc(userdoc: UserDocument) {
|
||||
return `${userdoc.username} (#${userdoc.id})`;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user