cleanup and remove web worker tests
All checks were successful
Deploy SSR / deploy (push) Successful in 1m16s
All checks were successful
Deploy SSR / deploy (push) Successful in 1m16s
This commit is contained in:
parent
bc2ddfa3a3
commit
37e2b305ff
@ -1,5 +1,5 @@
|
|||||||
import { scoresaberFetcher } from "@/common/data-fetcher/impl/scoresaber";
|
import { scoresaberService } from "@/common/service/impl/scoresaber";
|
||||||
import { ScoreSort } from "@/common/data-fetcher/sort";
|
import { ScoreSort } from "@/common/service/score-sort";
|
||||||
import { formatNumberWithCommas } from "@/common/number-utils";
|
import { formatNumberWithCommas } from "@/common/number-utils";
|
||||||
import PlayerData from "@/components/player/player-data";
|
import PlayerData from "@/components/player/player-data";
|
||||||
import { format } from "@formkit/tempo";
|
import { format } from "@formkit/tempo";
|
||||||
@ -16,7 +16,7 @@ export async function generateMetadata({
|
|||||||
params: { slug },
|
params: { slug },
|
||||||
}: Props): Promise<Metadata> {
|
}: Props): Promise<Metadata> {
|
||||||
const id = slug[0]; // The players id
|
const id = slug[0]; // The players id
|
||||||
const player = await scoresaberFetcher.lookupPlayer(id, false);
|
const player = await scoresaberService.lookupPlayer(id, false);
|
||||||
if (player === undefined) {
|
if (player === undefined) {
|
||||||
return {
|
return {
|
||||||
title: `Unknown Player`,
|
title: `Unknown Player`,
|
||||||
@ -44,8 +44,8 @@ export default async function Search({ params: { slug } }: Props) {
|
|||||||
const id = slug[0]; // The players id
|
const id = slug[0]; // The players id
|
||||||
const sort: ScoreSort = (slug[1] as ScoreSort) || "recent"; // The sorting method
|
const sort: ScoreSort = (slug[1] as ScoreSort) || "recent"; // The sorting method
|
||||||
const page = parseInt(slug[2]) || 1; // The page number
|
const page = parseInt(slug[2]) || 1; // The page number
|
||||||
const player = await scoresaberFetcher.lookupPlayer(id, false);
|
const player = await scoresaberService.lookupPlayer(id, false);
|
||||||
const scores = await scoresaberFetcher.lookupPlayerScores({
|
const scores = await scoresaberService.lookupPlayerScores({
|
||||||
playerId: id,
|
playerId: id,
|
||||||
sort,
|
sort,
|
||||||
page,
|
page,
|
||||||
|
@ -6,3 +6,13 @@
|
|||||||
export function copyToClipboard(str: string) {
|
export function copyToClipboard(str: string) {
|
||||||
navigator.clipboard.writeText(str);
|
navigator.clipboard.writeText(str);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if the current context is a worker
|
||||||
|
*/
|
||||||
|
export function isRunningAsWorker() {
|
||||||
|
if (typeof window === "undefined") {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return navigator.constructor.name === "WorkerNavigator";
|
||||||
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { BeatSaverMap as BSMap } from "@/common/data-fetcher/types/beatsaver/beatsaver-map";
|
import { BeatSaverMap as BSMap } from "@/common/service/types/beatsaver/beatsaver-map";
|
||||||
import { Entity } from "dexie";
|
import { Entity } from "dexie";
|
||||||
import Database from "../database";
|
import Database from "../database";
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import ScoreSaberPlayer from "@/common/data-fetcher/types/scoresaber/scoresaber-player";
|
import ScoreSaberPlayer from "@/common/service/types/scoresaber/scoresaber-player";
|
||||||
import { scoresaberFetcher } from "@/common/data-fetcher/impl/scoresaber";
|
import { scoresaberService } from "@/common/service/impl/scoresaber";
|
||||||
import { ScoreSort } from "@/common/data-fetcher/sort";
|
import { ScoreSort } from "@/common/service/score-sort";
|
||||||
|
|
||||||
export const leaderboards = {
|
export const leaderboards = {
|
||||||
ScoreSaber: {
|
ScoreSaber: {
|
||||||
@ -9,7 +9,7 @@ export const leaderboards = {
|
|||||||
},
|
},
|
||||||
queries: {
|
queries: {
|
||||||
lookupScores: (player: ScoreSaberPlayer, sort: ScoreSort, page: number) =>
|
lookupScores: (player: ScoreSaberPlayer, sort: ScoreSort, page: number) =>
|
||||||
scoresaberFetcher.lookupPlayerScores({
|
scoresaberService.lookupPlayerScores({
|
||||||
playerId: player.id,
|
playerId: player.id,
|
||||||
sort: sort,
|
sort: sort,
|
||||||
page: page,
|
page: page,
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
import BeatSaverMap from "@/common/database/types/beatsaver-map";
|
import BeatSaverMap from "@/common/database/types/beatsaver-map";
|
||||||
import { db } from "../../database/database";
|
import { db } from "../../database/database";
|
||||||
import DataFetcher from "../data-fetcher";
|
import Service from "../service";
|
||||||
import { BeatSaverMap as BSMap } from "../types/beatsaver/beatsaver-map";
|
import { BeatSaverMap as BSMap } from "../types/beatsaver/beatsaver-map";
|
||||||
|
|
||||||
const API_BASE = "https://api.beatsaver.com";
|
const API_BASE = "https://api.beatsaver.com";
|
||||||
const LOOKUP_MAP_BY_HASH_ENDPOINT = `${API_BASE}/maps/hash/:query`;
|
const LOOKUP_MAP_BY_HASH_ENDPOINT = `${API_BASE}/maps/hash/:query`;
|
||||||
|
|
||||||
class BeatSaverFetcher extends DataFetcher {
|
class BeatSaverService extends Service {
|
||||||
constructor() {
|
constructor() {
|
||||||
super("BeatSaver");
|
super("BeatSaver");
|
||||||
}
|
}
|
||||||
@ -62,4 +62,4 @@ class BeatSaverFetcher extends DataFetcher {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export const beatsaverFetcher = new BeatSaverFetcher();
|
export const beatsaverService = new BeatSaverService();
|
@ -1,5 +1,5 @@
|
|||||||
import DataFetcher from "../data-fetcher";
|
import Service from "../service";
|
||||||
import { ScoreSort } from "../sort";
|
import { ScoreSort } from "../score-sort";
|
||||||
import ScoreSaberLeaderboardScoresPage from "../types/scoresaber/scoresaber-leaderboard-scores-page";
|
import ScoreSaberLeaderboardScoresPage from "../types/scoresaber/scoresaber-leaderboard-scores-page";
|
||||||
import ScoreSaberPlayer from "../types/scoresaber/scoresaber-player";
|
import ScoreSaberPlayer from "../types/scoresaber/scoresaber-player";
|
||||||
import ScoreSaberPlayerScoresPage from "../types/scoresaber/scoresaber-player-scores-page";
|
import ScoreSaberPlayerScoresPage from "../types/scoresaber/scoresaber-player-scores-page";
|
||||||
@ -11,7 +11,7 @@ const LOOKUP_PLAYER_ENDPOINT = `${API_BASE}/player/:id/full`;
|
|||||||
const LOOKUP_PLAYER_SCORES_ENDPOINT = `${API_BASE}/player/:id/scores?limit=:limit&sort=:sort&page=:page`;
|
const LOOKUP_PLAYER_SCORES_ENDPOINT = `${API_BASE}/player/:id/scores?limit=:limit&sort=:sort&page=:page`;
|
||||||
const LOOKUP_LEADERBOARD_SCORES_ENDPOINT = `${API_BASE}/leaderboard/by-id/:id/scores?page=:page`;
|
const LOOKUP_LEADERBOARD_SCORES_ENDPOINT = `${API_BASE}/leaderboard/by-id/:id/scores?page=:page`;
|
||||||
|
|
||||||
class ScoreSaberFetcher extends DataFetcher {
|
class ScoreSaberService extends Service {
|
||||||
constructor() {
|
constructor() {
|
||||||
super("ScoreSaber");
|
super("ScoreSaber");
|
||||||
}
|
}
|
||||||
@ -110,7 +110,7 @@ class ScoreSaberFetcher extends DataFetcher {
|
|||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
this.log(
|
this.log(
|
||||||
`Found scores for player "${playerId}" in ${(performance.now() - before).toFixed(0)}ms`,
|
`Found ${response.playerScores.length} scores for player "${playerId}" in ${(performance.now() - before).toFixed(0)}ms`,
|
||||||
);
|
);
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
@ -144,10 +144,10 @@ class ScoreSaberFetcher extends DataFetcher {
|
|||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
this.log(
|
this.log(
|
||||||
`Found scores for leaderboard "${leaderboardId}" in ${(performance.now() - before).toFixed(0)}ms`,
|
`Found ${response.scores.length} scores for leaderboard "${leaderboardId}" in ${(performance.now() - before).toFixed(0)}ms`,
|
||||||
);
|
);
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export const scoresaberFetcher = new ScoreSaberFetcher();
|
export const scoresaberService = new ScoreSaberService();
|
@ -1,8 +1,9 @@
|
|||||||
import ky from "ky";
|
import ky from "ky";
|
||||||
|
import { isRunningAsWorker } from "@/common/browser-utils";
|
||||||
|
|
||||||
export default class DataFetcher {
|
export default class Service {
|
||||||
/**
|
/**
|
||||||
* The name of the leaderboard.
|
* The name of the service.
|
||||||
*/
|
*/
|
||||||
private name: string;
|
private name: string;
|
||||||
|
|
||||||
@ -16,7 +17,9 @@ export default class DataFetcher {
|
|||||||
* @param data the data to log
|
* @param data the data to log
|
||||||
*/
|
*/
|
||||||
public log(data: unknown) {
|
public log(data: unknown) {
|
||||||
console.debug(`[${this.name}]: ${data}`);
|
console.log(
|
||||||
|
`[${isRunningAsWorker() ? "Worker - " : ""}${this.name}]: ${data}`,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
@ -1,16 +1,16 @@
|
|||||||
import * as Comlink from "comlink";
|
import * as Comlink from "comlink";
|
||||||
import { scoresaberFetcher } from "@/common/data-fetcher/impl/scoresaber";
|
import { scoresaberService } from "@/common/service/impl/scoresaber";
|
||||||
|
|
||||||
export interface WorkerApi {
|
export interface WorkerApi {
|
||||||
getName: typeof getName;
|
getPlayerExample: typeof getPlayerExample;
|
||||||
}
|
}
|
||||||
|
|
||||||
const workerApi: WorkerApi = {
|
const workerApi: WorkerApi = {
|
||||||
getName,
|
getPlayerExample: getPlayerExample,
|
||||||
};
|
};
|
||||||
|
|
||||||
async function getName() {
|
async function getPlayerExample() {
|
||||||
return await scoresaberFetcher.lookupPlayer("76561198449412074");
|
return await scoresaberService.lookupPlayer("76561198449412074");
|
||||||
}
|
}
|
||||||
|
|
||||||
Comlink.expose(workerApi);
|
Comlink.expose(workerApi);
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import { scoresaberFetcher } from "@/common/data-fetcher/impl/scoresaber";
|
import { scoresaberService } from "@/common/service/impl/scoresaber";
|
||||||
import ScoreSaberPlayer from "@/common/data-fetcher/types/scoresaber/scoresaber-player";
|
import ScoreSaberPlayer from "@/common/service/types/scoresaber/scoresaber-player";
|
||||||
import { formatNumberWithCommas } from "@/common/number-utils";
|
import { formatNumberWithCommas } from "@/common/number-utils";
|
||||||
import { zodResolver } from "@hookform/resolvers/zod";
|
import { zodResolver } from "@hookform/resolvers/zod";
|
||||||
import Link from "next/link";
|
import Link from "next/link";
|
||||||
@ -31,7 +31,7 @@ export default function SearchPlayer() {
|
|||||||
async function onSubmit({ username }: z.infer<typeof formSchema>) {
|
async function onSubmit({ username }: z.infer<typeof formSchema>) {
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
setResults(undefined); // Reset results
|
setResults(undefined); // Reset results
|
||||||
const results = await scoresaberFetcher.searchPlayers(username);
|
const results = await scoresaberService.searchPlayers(username);
|
||||||
setResults(results?.players);
|
setResults(results?.players);
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import ScoreSaberScore from "@/common/data-fetcher/types/scoresaber/scoresaber-score";
|
import ScoreSaberScore from "@/common/service/types/scoresaber/scoresaber-score";
|
||||||
import Image from "next/image";
|
import Image from "next/image";
|
||||||
import Link from "next/link";
|
import Link from "next/link";
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import ScoreSaberLeaderboard from "@/common/data-fetcher/types/scoresaber/scoresaber-leaderboard";
|
import ScoreSaberLeaderboard from "@/common/service/types/scoresaber/scoresaber-leaderboard";
|
||||||
import ScoreSaberScore from "@/common/data-fetcher/types/scoresaber/scoresaber-score";
|
import ScoreSaberScore from "@/common/service/types/scoresaber/scoresaber-score";
|
||||||
import { formatNumberWithCommas } from "@/common/number-utils";
|
import { formatNumberWithCommas } from "@/common/number-utils";
|
||||||
import StatValue from "@/components/stat-value";
|
import StatValue from "@/components/stat-value";
|
||||||
import { XMarkIcon } from "@heroicons/react/24/solid";
|
import { XMarkIcon } from "@heroicons/react/24/solid";
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import ScoreSaberLeaderboard from "@/common/data-fetcher/types/scoresaber/scoresaber-leaderboard";
|
import ScoreSaberLeaderboard from "@/common/service/types/scoresaber/scoresaber-leaderboard";
|
||||||
import ScoreSaberScore from "@/common/data-fetcher/types/scoresaber/scoresaber-score";
|
import ScoreSaberScore from "@/common/service/types/scoresaber/scoresaber-score";
|
||||||
import ScoreRankInfo from "../player/score/score-rank-info";
|
import ScoreRankInfo from "../player/score/score-rank-info";
|
||||||
import LeaderboardPlayer from "./leaderboard-player";
|
import LeaderboardPlayer from "./leaderboard-player";
|
||||||
import LeaderboardScoreStats from "./leaderboard-score-stats";
|
import LeaderboardScoreStats from "./leaderboard-score-stats";
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import { scoresaberFetcher } from "@/common/data-fetcher/impl/scoresaber";
|
import { scoresaberService } from "@/common/service/impl/scoresaber";
|
||||||
import ScoreSaberLeaderboard from "@/common/data-fetcher/types/scoresaber/scoresaber-leaderboard";
|
import ScoreSaberLeaderboard from "@/common/service/types/scoresaber/scoresaber-leaderboard";
|
||||||
import ScoreSaberLeaderboardScoresPage from "@/common/data-fetcher/types/scoresaber/scoresaber-leaderboard-scores-page";
|
import ScoreSaberLeaderboardScoresPage from "@/common/service/types/scoresaber/scoresaber-leaderboard-scores-page";
|
||||||
import useWindowDimensions from "@/hooks/use-window-dimensions";
|
import useWindowDimensions from "@/hooks/use-window-dimensions";
|
||||||
import { useQuery } from "@tanstack/react-query";
|
import { useQuery } from "@tanstack/react-query";
|
||||||
import { motion } from "framer-motion";
|
import { motion } from "framer-motion";
|
||||||
@ -31,7 +31,7 @@ export default function LeaderboardScores({ leaderboard }: Props) {
|
|||||||
} = useQuery({
|
} = useQuery({
|
||||||
queryKey: ["playerScores", leaderboard.id, currentPage],
|
queryKey: ["playerScores", leaderboard.id, currentPage],
|
||||||
queryFn: () =>
|
queryFn: () =>
|
||||||
scoresaberFetcher.lookupLeaderboardScores(
|
scoresaberService.lookupLeaderboardScores(
|
||||||
leaderboard.id + "",
|
leaderboard.id + "",
|
||||||
currentPage,
|
currentPage,
|
||||||
),
|
),
|
||||||
|
@ -2,9 +2,9 @@
|
|||||||
|
|
||||||
import { CheckIcon } from "@heroicons/react/24/solid";
|
import { CheckIcon } from "@heroicons/react/24/solid";
|
||||||
import { useLiveQuery } from "dexie-react-hooks";
|
import { useLiveQuery } from "dexie-react-hooks";
|
||||||
import { setPlayerIdCookie } from "../../common/website-utils";
|
import { setPlayerIdCookie } from "@/common/website-utils";
|
||||||
import useDatabase from "../../hooks/use-database";
|
import useDatabase from "../../hooks/use-database";
|
||||||
import { useToast } from "../../hooks/use-toast";
|
import { useToast } from "@/hooks/use-toast";
|
||||||
import Tooltip from "../tooltip";
|
import Tooltip from "../tooltip";
|
||||||
import { Button } from "../ui/button";
|
import { Button } from "../ui/button";
|
||||||
|
|
||||||
|
@ -1,15 +1,13 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import { scoresaberFetcher } from "@/common/data-fetcher/impl/scoresaber";
|
import { scoresaberService } from "@/common/service/impl/scoresaber";
|
||||||
import { ScoreSort } from "@/common/data-fetcher/sort";
|
import { ScoreSort } from "@/common/service/score-sort";
|
||||||
import ScoreSaberPlayer from "@/common/data-fetcher/types/scoresaber/scoresaber-player";
|
import ScoreSaberPlayer from "@/common/service/types/scoresaber/scoresaber-player";
|
||||||
import ScoreSaberPlayerScoresPage from "@/common/data-fetcher/types/scoresaber/scoresaber-player-scores-page";
|
import ScoreSaberPlayerScoresPage from "@/common/service/types/scoresaber/scoresaber-player-scores-page";
|
||||||
import { useQuery } from "@tanstack/react-query";
|
import { useQuery } from "@tanstack/react-query";
|
||||||
import PlayerHeader from "./player-header";
|
import PlayerHeader from "./player-header";
|
||||||
import PlayerRankChart from "./player-rank-chart";
|
import PlayerRankChart from "./player-rank-chart";
|
||||||
import PlayerScores from "./player-scores";
|
import PlayerScores from "./player-scores";
|
||||||
import { useEffect } from "react";
|
|
||||||
import { scoresaberReloadedWorker } from "@/common/workers/workers";
|
|
||||||
|
|
||||||
const REFRESH_INTERVAL = 5 * 60 * 1000; // 5 minutes
|
const REFRESH_INTERVAL = 5 * 60 * 1000; // 5 minutes
|
||||||
|
|
||||||
@ -29,17 +27,10 @@ export default function PlayerData({
|
|||||||
let player = initalPlayerData;
|
let player = initalPlayerData;
|
||||||
const { data, isLoading, isError } = useQuery({
|
const { data, isLoading, isError } = useQuery({
|
||||||
queryKey: ["player", player.id],
|
queryKey: ["player", player.id],
|
||||||
queryFn: () => scoresaberFetcher.lookupPlayer(player.id),
|
queryFn: () => scoresaberService.lookupPlayer(player.id),
|
||||||
refetchInterval: REFRESH_INTERVAL,
|
refetchInterval: REFRESH_INTERVAL,
|
||||||
});
|
});
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
(async () => {
|
|
||||||
const worker = scoresaberReloadedWorker();
|
|
||||||
console.log(await worker.getName());
|
|
||||||
})();
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
if (data && (!isLoading || !isError)) {
|
if (data && (!isLoading || !isError)) {
|
||||||
player = data;
|
player = data;
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import ScoreSaberPlayer from "@/common/data-fetcher/types/scoresaber/scoresaber-player";
|
import ScoreSaberPlayer from "@/common/service/types/scoresaber/scoresaber-player";
|
||||||
import { formatNumberWithCommas } from "@/common/number-utils";
|
import { formatNumberWithCommas } from "@/common/number-utils";
|
||||||
import { GlobeAmericasIcon } from "@heroicons/react/24/solid";
|
import { GlobeAmericasIcon } from "@heroicons/react/24/solid";
|
||||||
import Card from "../card";
|
import Card from "../card";
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/* eslint-disable @typescript-eslint/no-explicit-any */
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import ScoreSaberPlayer from "@/common/data-fetcher/types/scoresaber/scoresaber-player";
|
import ScoreSaberPlayer from "@/common/service/types/scoresaber/scoresaber-player";
|
||||||
import { formatNumberWithCommas } from "@/common/number-utils";
|
import { formatNumberWithCommas } from "@/common/number-utils";
|
||||||
import {
|
import {
|
||||||
CategoryScale,
|
CategoryScale,
|
||||||
|
@ -1,8 +1,5 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import { ScoreSort } from "@/common/data-fetcher/sort";
|
|
||||||
import ScoreSaberPlayer from "@/common/data-fetcher/types/scoresaber/scoresaber-player";
|
|
||||||
import ScoreSaberPlayerScoresPage from "@/common/data-fetcher/types/scoresaber/scoresaber-player-scores-page";
|
|
||||||
import { capitalizeFirstLetter } from "@/common/string-utils";
|
import { capitalizeFirstLetter } from "@/common/string-utils";
|
||||||
import useWindowDimensions from "@/hooks/use-window-dimensions";
|
import useWindowDimensions from "@/hooks/use-window-dimensions";
|
||||||
import { ClockIcon, TrophyIcon } from "@heroicons/react/24/solid";
|
import { ClockIcon, TrophyIcon } from "@heroicons/react/24/solid";
|
||||||
@ -14,6 +11,9 @@ import Pagination from "../input/pagination";
|
|||||||
import { Button } from "../ui/button";
|
import { Button } from "../ui/button";
|
||||||
import Score from "./score/score";
|
import Score from "./score/score";
|
||||||
import { leaderboards } from "@/common/leaderboards";
|
import { leaderboards } from "@/common/leaderboards";
|
||||||
|
import { ScoreSort } from "@/common/service/score-sort";
|
||||||
|
import ScoreSaberPlayer from "@/common/service/types/scoresaber/scoresaber-player";
|
||||||
|
import ScoreSaberPlayerScoresPage from "@/common/service/types/scoresaber/scoresaber-player-scores-page";
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
initialScoreData?: ScoreSaberPlayerScoresPage;
|
initialScoreData?: ScoreSaberPlayerScoresPage;
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import ScoreSaberPlayer from "@/common/data-fetcher/types/scoresaber/scoresaber-player";
|
|
||||||
import { formatNumberWithCommas } from "@/common/number-utils";
|
import { formatNumberWithCommas } from "@/common/number-utils";
|
||||||
import StatValue from "@/components/stat-value";
|
import StatValue from "@/components/stat-value";
|
||||||
|
import ScoreSaberPlayer from "@/common/service/types/scoresaber/scoresaber-player";
|
||||||
|
|
||||||
type Badge = {
|
type Badge = {
|
||||||
name: string;
|
name: string;
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import { copyToClipboard } from "@/common/browser-utils";
|
import { copyToClipboard } from "@/common/browser-utils";
|
||||||
import ScoreSaberPlayerScore from "@/common/data-fetcher/types/scoresaber/scoresaber-player-score";
|
import ScoreSaberPlayerScore from "@/common/service/types/scoresaber/scoresaber-player-score";
|
||||||
import BeatSaverMap from "@/common/database/types/beatsaver-map";
|
import BeatSaverMap from "@/common/database/types/beatsaver-map";
|
||||||
import { songNameToYouTubeLink } from "@/common/youtube-utils";
|
import { songNameToYouTubeLink } from "@/common/youtube-utils";
|
||||||
import BeatSaverLogo from "@/components/logos/beatsaver-logo";
|
import BeatSaverLogo from "@/components/logos/beatsaver-logo";
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import ScoreSaberLeaderboard from "@/common/data-fetcher/types/scoresaber/scoresaber-leaderboard";
|
import ScoreSaberLeaderboard from "@/common/service/types/scoresaber/scoresaber-leaderboard";
|
||||||
import BeatSaverMap from "@/common/database/types/beatsaver-map";
|
import BeatSaverMap from "@/common/database/types/beatsaver-map";
|
||||||
import { getDifficultyFromScoreSaberDifficulty } from "@/common/scoresaber-utils";
|
import { getDifficultyFromScoreSaberDifficulty } from "@/common/scoresaber-utils";
|
||||||
import { songDifficultyToColor } from "@/common/song-utils";
|
import { songDifficultyToColor } from "@/common/song-utils";
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import ScoreSaberScore from "@/common/data-fetcher/types/scoresaber/scoresaber-score";
|
import ScoreSaberScore from "@/common/service/types/scoresaber/scoresaber-score";
|
||||||
import { formatNumberWithCommas } from "@/common/number-utils";
|
import { formatNumberWithCommas } from "@/common/number-utils";
|
||||||
import { timeAgo } from "@/common/time-utils";
|
import { timeAgo } from "@/common/time-utils";
|
||||||
import { GlobeAmericasIcon } from "@heroicons/react/24/solid";
|
import { GlobeAmericasIcon } from "@heroicons/react/24/solid";
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import ScoreSaberLeaderboard from "@/common/data-fetcher/types/scoresaber/scoresaber-leaderboard";
|
import ScoreSaberLeaderboard from "@/common/service/types/scoresaber/scoresaber-leaderboard";
|
||||||
import ScoreSaberScore from "@/common/data-fetcher/types/scoresaber/scoresaber-score";
|
import ScoreSaberScore from "@/common/service/types/scoresaber/scoresaber-score";
|
||||||
import { formatNumberWithCommas } from "@/common/number-utils";
|
import { formatNumberWithCommas } from "@/common/number-utils";
|
||||||
import StatValue from "@/components/stat-value";
|
import StatValue from "@/components/stat-value";
|
||||||
import { XMarkIcon } from "@heroicons/react/24/solid";
|
import { XMarkIcon } from "@heroicons/react/24/solid";
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import { beatsaverFetcher } from "@/common/data-fetcher/impl/beatsaver";
|
import { beatsaverService } from "@/common/service/impl/beatsaver";
|
||||||
import ScoreSaberPlayerScore from "@/common/data-fetcher/types/scoresaber/scoresaber-player-score";
|
import ScoreSaberPlayerScore from "@/common/service/types/scoresaber/scoresaber-player-score";
|
||||||
import BeatSaverMap from "@/common/database/types/beatsaver-map";
|
import BeatSaverMap from "@/common/database/types/beatsaver-map";
|
||||||
import LeaderboardScores from "@/components/leaderboard/leaderboard-scores";
|
import LeaderboardScores from "@/components/leaderboard/leaderboard-scores";
|
||||||
import { useCallback, useEffect, useState } from "react";
|
import { useCallback, useEffect, useState } from "react";
|
||||||
@ -23,7 +23,7 @@ export default function Score({ playerScore }: Props) {
|
|||||||
const [isLeaderboardExpanded, setIsLeaderboardExpanded] = useState(false);
|
const [isLeaderboardExpanded, setIsLeaderboardExpanded] = useState(false);
|
||||||
|
|
||||||
const fetchBeatSaverData = useCallback(async () => {
|
const fetchBeatSaverData = useCallback(async () => {
|
||||||
const beatSaverMap = await beatsaverFetcher.lookupMap(leaderboard.songHash);
|
const beatSaverMap = await beatsaverService.lookupMap(leaderboard.songHash);
|
||||||
setBeatSaverMap(beatSaverMap);
|
setBeatSaverMap(beatSaverMap);
|
||||||
}, [leaderboard.songHash]);
|
}, [leaderboard.songHash]);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user