diff --git a/src/app/(pages)/player/[...slug]/page.tsx b/src/app/(pages)/player/[...slug]/page.tsx index 3274765..e083c4f 100644 --- a/src/app/(pages)/player/[...slug]/page.tsx +++ b/src/app/(pages)/player/[...slug]/page.tsx @@ -1,5 +1,5 @@ -import { scoresaberFetcher } from "@/common/data-fetcher/impl/scoresaber"; -import { ScoreSort } from "@/common/data-fetcher/sort"; +import { scoresaberService } from "@/common/service/impl/scoresaber"; +import { ScoreSort } from "@/common/service/score-sort"; import { formatNumberWithCommas } from "@/common/number-utils"; import PlayerData from "@/components/player/player-data"; import { format } from "@formkit/tempo"; @@ -16,7 +16,7 @@ export async function generateMetadata({ params: { slug }, }: Props): Promise { const id = slug[0]; // The players id - const player = await scoresaberFetcher.lookupPlayer(id, false); + const player = await scoresaberService.lookupPlayer(id, false); if (player === undefined) { return { title: `Unknown Player`, @@ -44,8 +44,8 @@ export default async function Search({ params: { slug } }: Props) { const id = slug[0]; // The players id const sort: ScoreSort = (slug[1] as ScoreSort) || "recent"; // The sorting method const page = parseInt(slug[2]) || 1; // The page number - const player = await scoresaberFetcher.lookupPlayer(id, false); - const scores = await scoresaberFetcher.lookupPlayerScores({ + const player = await scoresaberService.lookupPlayer(id, false); + const scores = await scoresaberService.lookupPlayerScores({ playerId: id, sort, page, diff --git a/src/common/browser-utils.ts b/src/common/browser-utils.ts index 7183936..f7bbf19 100644 --- a/src/common/browser-utils.ts +++ b/src/common/browser-utils.ts @@ -6,3 +6,13 @@ export function copyToClipboard(str: string) { 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"; +} diff --git a/src/common/database/types/beatsaver-map.ts b/src/common/database/types/beatsaver-map.ts index 0d97d2f..6fcaf09 100644 --- a/src/common/database/types/beatsaver-map.ts +++ b/src/common/database/types/beatsaver-map.ts @@ -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 Database from "../database"; diff --git a/src/common/leaderboards.ts b/src/common/leaderboards.ts index da80bcc..980896c 100644 --- a/src/common/leaderboards.ts +++ b/src/common/leaderboards.ts @@ -1,6 +1,6 @@ -import ScoreSaberPlayer from "@/common/data-fetcher/types/scoresaber/scoresaber-player"; -import { scoresaberFetcher } from "@/common/data-fetcher/impl/scoresaber"; -import { ScoreSort } from "@/common/data-fetcher/sort"; +import ScoreSaberPlayer from "@/common/service/types/scoresaber/scoresaber-player"; +import { scoresaberService } from "@/common/service/impl/scoresaber"; +import { ScoreSort } from "@/common/service/score-sort"; export const leaderboards = { ScoreSaber: { @@ -9,7 +9,7 @@ export const leaderboards = { }, queries: { lookupScores: (player: ScoreSaberPlayer, sort: ScoreSort, page: number) => - scoresaberFetcher.lookupPlayerScores({ + scoresaberService.lookupPlayerScores({ playerId: player.id, sort: sort, page: page, diff --git a/src/common/data-fetcher/impl/beatsaver.ts b/src/common/service/impl/beatsaver.ts similarity index 91% rename from src/common/data-fetcher/impl/beatsaver.ts rename to src/common/service/impl/beatsaver.ts index ef5182a..58c15fb 100644 --- a/src/common/data-fetcher/impl/beatsaver.ts +++ b/src/common/service/impl/beatsaver.ts @@ -1,12 +1,12 @@ import BeatSaverMap from "@/common/database/types/beatsaver-map"; import { db } from "../../database/database"; -import DataFetcher from "../data-fetcher"; +import Service from "../service"; import { BeatSaverMap as BSMap } from "../types/beatsaver/beatsaver-map"; const API_BASE = "https://api.beatsaver.com"; const LOOKUP_MAP_BY_HASH_ENDPOINT = `${API_BASE}/maps/hash/:query`; -class BeatSaverFetcher extends DataFetcher { +class BeatSaverService extends Service { constructor() { super("BeatSaver"); } @@ -62,4 +62,4 @@ class BeatSaverFetcher extends DataFetcher { } } -export const beatsaverFetcher = new BeatSaverFetcher(); +export const beatsaverService = new BeatSaverService(); diff --git a/src/common/data-fetcher/impl/scoresaber.ts b/src/common/service/impl/scoresaber.ts similarity index 91% rename from src/common/data-fetcher/impl/scoresaber.ts rename to src/common/service/impl/scoresaber.ts index cb8e945..67d3dd4 100644 --- a/src/common/data-fetcher/impl/scoresaber.ts +++ b/src/common/service/impl/scoresaber.ts @@ -1,5 +1,5 @@ -import DataFetcher from "../data-fetcher"; -import { ScoreSort } from "../sort"; +import Service from "../service"; +import { ScoreSort } from "../score-sort"; import ScoreSaberLeaderboardScoresPage from "../types/scoresaber/scoresaber-leaderboard-scores-page"; import ScoreSaberPlayer from "../types/scoresaber/scoresaber-player"; 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_LEADERBOARD_SCORES_ENDPOINT = `${API_BASE}/leaderboard/by-id/:id/scores?page=:page`; -class ScoreSaberFetcher extends DataFetcher { +class ScoreSaberService extends Service { constructor() { super("ScoreSaber"); } @@ -110,7 +110,7 @@ class ScoreSaberFetcher extends DataFetcher { return undefined; } 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; } @@ -144,10 +144,10 @@ class ScoreSaberFetcher extends DataFetcher { return undefined; } 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; } } -export const scoresaberFetcher = new ScoreSaberFetcher(); +export const scoresaberService = new ScoreSaberService(); diff --git a/src/common/data-fetcher/sort.ts b/src/common/service/score-sort.ts similarity index 100% rename from src/common/data-fetcher/sort.ts rename to src/common/service/score-sort.ts diff --git a/src/common/data-fetcher/data-fetcher.ts b/src/common/service/service.ts similarity index 84% rename from src/common/data-fetcher/data-fetcher.ts rename to src/common/service/service.ts index e64abcd..88d0e0f 100644 --- a/src/common/data-fetcher/data-fetcher.ts +++ b/src/common/service/service.ts @@ -1,8 +1,9 @@ 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; @@ -16,7 +17,9 @@ export default class DataFetcher { * @param data the data to log */ public log(data: unknown) { - console.debug(`[${this.name}]: ${data}`); + console.log( + `[${isRunningAsWorker() ? "Worker - " : ""}${this.name}]: ${data}`, + ); } /** diff --git a/src/common/data-fetcher/types/beatsaver/beatsaver-account.ts b/src/common/service/types/beatsaver/beatsaver-account.ts similarity index 100% rename from src/common/data-fetcher/types/beatsaver/beatsaver-account.ts rename to src/common/service/types/beatsaver/beatsaver-account.ts diff --git a/src/common/data-fetcher/types/beatsaver/beatsaver-map-metadata.ts b/src/common/service/types/beatsaver/beatsaver-map-metadata.ts similarity index 100% rename from src/common/data-fetcher/types/beatsaver/beatsaver-map-metadata.ts rename to src/common/service/types/beatsaver/beatsaver-map-metadata.ts diff --git a/src/common/data-fetcher/types/beatsaver/beatsaver-map-stats.ts b/src/common/service/types/beatsaver/beatsaver-map-stats.ts similarity index 100% rename from src/common/data-fetcher/types/beatsaver/beatsaver-map-stats.ts rename to src/common/service/types/beatsaver/beatsaver-map-stats.ts diff --git a/src/common/data-fetcher/types/beatsaver/beatsaver-map.ts b/src/common/service/types/beatsaver/beatsaver-map.ts similarity index 100% rename from src/common/data-fetcher/types/beatsaver/beatsaver-map.ts rename to src/common/service/types/beatsaver/beatsaver-map.ts diff --git a/src/common/data-fetcher/types/scoresaber/scoresaber-badge.ts b/src/common/service/types/scoresaber/scoresaber-badge.ts similarity index 100% rename from src/common/data-fetcher/types/scoresaber/scoresaber-badge.ts rename to src/common/service/types/scoresaber/scoresaber-badge.ts diff --git a/src/common/data-fetcher/types/scoresaber/scoresaber-difficulty.ts b/src/common/service/types/scoresaber/scoresaber-difficulty.ts similarity index 100% rename from src/common/data-fetcher/types/scoresaber/scoresaber-difficulty.ts rename to src/common/service/types/scoresaber/scoresaber-difficulty.ts diff --git a/src/common/data-fetcher/types/scoresaber/scoresaber-leaderboard-player-info.ts b/src/common/service/types/scoresaber/scoresaber-leaderboard-player-info.ts similarity index 100% rename from src/common/data-fetcher/types/scoresaber/scoresaber-leaderboard-player-info.ts rename to src/common/service/types/scoresaber/scoresaber-leaderboard-player-info.ts diff --git a/src/common/data-fetcher/types/scoresaber/scoresaber-leaderboard-scores-page.ts b/src/common/service/types/scoresaber/scoresaber-leaderboard-scores-page.ts similarity index 100% rename from src/common/data-fetcher/types/scoresaber/scoresaber-leaderboard-scores-page.ts rename to src/common/service/types/scoresaber/scoresaber-leaderboard-scores-page.ts diff --git a/src/common/data-fetcher/types/scoresaber/scoresaber-leaderboard.ts b/src/common/service/types/scoresaber/scoresaber-leaderboard.ts similarity index 100% rename from src/common/data-fetcher/types/scoresaber/scoresaber-leaderboard.ts rename to src/common/service/types/scoresaber/scoresaber-leaderboard.ts diff --git a/src/common/data-fetcher/types/scoresaber/scoresaber-metadata.ts b/src/common/service/types/scoresaber/scoresaber-metadata.ts similarity index 100% rename from src/common/data-fetcher/types/scoresaber/scoresaber-metadata.ts rename to src/common/service/types/scoresaber/scoresaber-metadata.ts diff --git a/src/common/data-fetcher/types/scoresaber/scoresaber-player-score.ts b/src/common/service/types/scoresaber/scoresaber-player-score.ts similarity index 100% rename from src/common/data-fetcher/types/scoresaber/scoresaber-player-score.ts rename to src/common/service/types/scoresaber/scoresaber-player-score.ts diff --git a/src/common/data-fetcher/types/scoresaber/scoresaber-player-scores-page.ts b/src/common/service/types/scoresaber/scoresaber-player-scores-page.ts similarity index 100% rename from src/common/data-fetcher/types/scoresaber/scoresaber-player-scores-page.ts rename to src/common/service/types/scoresaber/scoresaber-player-scores-page.ts diff --git a/src/common/data-fetcher/types/scoresaber/scoresaber-player-search.ts b/src/common/service/types/scoresaber/scoresaber-player-search.ts similarity index 100% rename from src/common/data-fetcher/types/scoresaber/scoresaber-player-search.ts rename to src/common/service/types/scoresaber/scoresaber-player-search.ts diff --git a/src/common/data-fetcher/types/scoresaber/scoresaber-player.ts b/src/common/service/types/scoresaber/scoresaber-player.ts similarity index 100% rename from src/common/data-fetcher/types/scoresaber/scoresaber-player.ts rename to src/common/service/types/scoresaber/scoresaber-player.ts diff --git a/src/common/data-fetcher/types/scoresaber/scoresaber-score-stats.ts b/src/common/service/types/scoresaber/scoresaber-score-stats.ts similarity index 100% rename from src/common/data-fetcher/types/scoresaber/scoresaber-score-stats.ts rename to src/common/service/types/scoresaber/scoresaber-score-stats.ts diff --git a/src/common/data-fetcher/types/scoresaber/scoresaber-score.ts b/src/common/service/types/scoresaber/scoresaber-score.ts similarity index 100% rename from src/common/data-fetcher/types/scoresaber/scoresaber-score.ts rename to src/common/service/types/scoresaber/scoresaber-score.ts diff --git a/src/common/workers/worker.ts b/src/common/workers/worker.ts index 0011f99..2d8bd4f 100644 --- a/src/common/workers/worker.ts +++ b/src/common/workers/worker.ts @@ -1,16 +1,16 @@ import * as Comlink from "comlink"; -import { scoresaberFetcher } from "@/common/data-fetcher/impl/scoresaber"; +import { scoresaberService } from "@/common/service/impl/scoresaber"; export interface WorkerApi { - getName: typeof getName; + getPlayerExample: typeof getPlayerExample; } const workerApi: WorkerApi = { - getName, + getPlayerExample: getPlayerExample, }; -async function getName() { - return await scoresaberFetcher.lookupPlayer("76561198449412074"); +async function getPlayerExample() { + return await scoresaberService.lookupPlayer("76561198449412074"); } Comlink.expose(workerApi); diff --git a/src/components/input/search-player.tsx b/src/components/input/search-player.tsx index 2a8c072..13c60c9 100644 --- a/src/components/input/search-player.tsx +++ b/src/components/input/search-player.tsx @@ -1,7 +1,7 @@ "use client"; -import { scoresaberFetcher } from "@/common/data-fetcher/impl/scoresaber"; -import ScoreSaberPlayer from "@/common/data-fetcher/types/scoresaber/scoresaber-player"; +import { scoresaberService } from "@/common/service/impl/scoresaber"; +import ScoreSaberPlayer from "@/common/service/types/scoresaber/scoresaber-player"; import { formatNumberWithCommas } from "@/common/number-utils"; import { zodResolver } from "@hookform/resolvers/zod"; import Link from "next/link"; @@ -31,7 +31,7 @@ export default function SearchPlayer() { async function onSubmit({ username }: z.infer) { setLoading(true); setResults(undefined); // Reset results - const results = await scoresaberFetcher.searchPlayers(username); + const results = await scoresaberService.searchPlayers(username); setResults(results?.players); setLoading(false); } diff --git a/src/components/leaderboard/leaderboard-player.tsx b/src/components/leaderboard/leaderboard-player.tsx index 832ac2c..a7773d1 100644 --- a/src/components/leaderboard/leaderboard-player.tsx +++ b/src/components/leaderboard/leaderboard-player.tsx @@ -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 Link from "next/link"; diff --git a/src/components/leaderboard/leaderboard-score-stats.tsx b/src/components/leaderboard/leaderboard-score-stats.tsx index 17e3fed..184db8b 100644 --- a/src/components/leaderboard/leaderboard-score-stats.tsx +++ b/src/components/leaderboard/leaderboard-score-stats.tsx @@ -1,5 +1,5 @@ -import ScoreSaberLeaderboard from "@/common/data-fetcher/types/scoresaber/scoresaber-leaderboard"; -import ScoreSaberScore from "@/common/data-fetcher/types/scoresaber/scoresaber-score"; +import ScoreSaberLeaderboard from "@/common/service/types/scoresaber/scoresaber-leaderboard"; +import ScoreSaberScore from "@/common/service/types/scoresaber/scoresaber-score"; import { formatNumberWithCommas } from "@/common/number-utils"; import StatValue from "@/components/stat-value"; import { XMarkIcon } from "@heroicons/react/24/solid"; diff --git a/src/components/leaderboard/leaderboard-score.tsx b/src/components/leaderboard/leaderboard-score.tsx index d6fb01b..dc48160 100644 --- a/src/components/leaderboard/leaderboard-score.tsx +++ b/src/components/leaderboard/leaderboard-score.tsx @@ -1,7 +1,7 @@ "use client"; -import ScoreSaberLeaderboard from "@/common/data-fetcher/types/scoresaber/scoresaber-leaderboard"; -import ScoreSaberScore from "@/common/data-fetcher/types/scoresaber/scoresaber-score"; +import ScoreSaberLeaderboard from "@/common/service/types/scoresaber/scoresaber-leaderboard"; +import ScoreSaberScore from "@/common/service/types/scoresaber/scoresaber-score"; import ScoreRankInfo from "../player/score/score-rank-info"; import LeaderboardPlayer from "./leaderboard-player"; import LeaderboardScoreStats from "./leaderboard-score-stats"; diff --git a/src/components/leaderboard/leaderboard-scores.tsx b/src/components/leaderboard/leaderboard-scores.tsx index ee804b0..8e49fff 100644 --- a/src/components/leaderboard/leaderboard-scores.tsx +++ b/src/components/leaderboard/leaderboard-scores.tsx @@ -1,8 +1,8 @@ "use client"; -import { scoresaberFetcher } from "@/common/data-fetcher/impl/scoresaber"; -import ScoreSaberLeaderboard from "@/common/data-fetcher/types/scoresaber/scoresaber-leaderboard"; -import ScoreSaberLeaderboardScoresPage from "@/common/data-fetcher/types/scoresaber/scoresaber-leaderboard-scores-page"; +import { scoresaberService } from "@/common/service/impl/scoresaber"; +import ScoreSaberLeaderboard from "@/common/service/types/scoresaber/scoresaber-leaderboard"; +import ScoreSaberLeaderboardScoresPage from "@/common/service/types/scoresaber/scoresaber-leaderboard-scores-page"; import useWindowDimensions from "@/hooks/use-window-dimensions"; import { useQuery } from "@tanstack/react-query"; import { motion } from "framer-motion"; @@ -31,7 +31,7 @@ export default function LeaderboardScores({ leaderboard }: Props) { } = useQuery({ queryKey: ["playerScores", leaderboard.id, currentPage], queryFn: () => - scoresaberFetcher.lookupLeaderboardScores( + scoresaberService.lookupLeaderboardScores( leaderboard.id + "", currentPage, ), diff --git a/src/components/player/claim-profile.tsx b/src/components/player/claim-profile.tsx index 2751424..430a7de 100644 --- a/src/components/player/claim-profile.tsx +++ b/src/components/player/claim-profile.tsx @@ -2,9 +2,9 @@ import { CheckIcon } from "@heroicons/react/24/solid"; 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 { useToast } from "../../hooks/use-toast"; +import { useToast } from "@/hooks/use-toast"; import Tooltip from "../tooltip"; import { Button } from "../ui/button"; diff --git a/src/components/player/player-data.tsx b/src/components/player/player-data.tsx index 9482644..3f3e1ae 100644 --- a/src/components/player/player-data.tsx +++ b/src/components/player/player-data.tsx @@ -1,15 +1,13 @@ "use client"; -import { scoresaberFetcher } from "@/common/data-fetcher/impl/scoresaber"; -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 { scoresaberService } from "@/common/service/impl/scoresaber"; +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"; import { useQuery } from "@tanstack/react-query"; import PlayerHeader from "./player-header"; import PlayerRankChart from "./player-rank-chart"; import PlayerScores from "./player-scores"; -import { useEffect } from "react"; -import { scoresaberReloadedWorker } from "@/common/workers/workers"; const REFRESH_INTERVAL = 5 * 60 * 1000; // 5 minutes @@ -29,17 +27,10 @@ export default function PlayerData({ let player = initalPlayerData; const { data, isLoading, isError } = useQuery({ queryKey: ["player", player.id], - queryFn: () => scoresaberFetcher.lookupPlayer(player.id), + queryFn: () => scoresaberService.lookupPlayer(player.id), refetchInterval: REFRESH_INTERVAL, }); - useEffect(() => { - (async () => { - const worker = scoresaberReloadedWorker(); - console.log(await worker.getName()); - })(); - }, []); - if (data && (!isLoading || !isError)) { player = data; } diff --git a/src/components/player/player-header.tsx b/src/components/player/player-header.tsx index 0090197..0d9ed23 100644 --- a/src/components/player/player-header.tsx +++ b/src/components/player/player-header.tsx @@ -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 { GlobeAmericasIcon } from "@heroicons/react/24/solid"; import Card from "../card"; diff --git a/src/components/player/player-rank-chart.tsx b/src/components/player/player-rank-chart.tsx index 2be7393..b33866c 100644 --- a/src/components/player/player-rank-chart.tsx +++ b/src/components/player/player-rank-chart.tsx @@ -1,7 +1,7 @@ /* eslint-disable @typescript-eslint/no-explicit-any */ "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 { CategoryScale, diff --git a/src/components/player/player-scores.tsx b/src/components/player/player-scores.tsx index 00f94cb..47d82d2 100644 --- a/src/components/player/player-scores.tsx +++ b/src/components/player/player-scores.tsx @@ -1,8 +1,5 @@ "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 useWindowDimensions from "@/hooks/use-window-dimensions"; import { ClockIcon, TrophyIcon } from "@heroicons/react/24/solid"; @@ -14,6 +11,9 @@ import Pagination from "../input/pagination"; import { Button } from "../ui/button"; import Score from "./score/score"; 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 = { initialScoreData?: ScoreSaberPlayerScoresPage; diff --git a/src/components/player/player-stats.tsx b/src/components/player/player-stats.tsx index e084ff0..aed9658 100644 --- a/src/components/player/player-stats.tsx +++ b/src/components/player/player-stats.tsx @@ -1,6 +1,6 @@ -import ScoreSaberPlayer from "@/common/data-fetcher/types/scoresaber/scoresaber-player"; import { formatNumberWithCommas } from "@/common/number-utils"; import StatValue from "@/components/stat-value"; +import ScoreSaberPlayer from "@/common/service/types/scoresaber/scoresaber-player"; type Badge = { name: string; diff --git a/src/components/player/score/score-buttons.tsx b/src/components/player/score/score-buttons.tsx index e2e150b..99076d0 100644 --- a/src/components/player/score/score-buttons.tsx +++ b/src/components/player/score/score-buttons.tsx @@ -1,7 +1,7 @@ "use client"; 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 { songNameToYouTubeLink } from "@/common/youtube-utils"; import BeatSaverLogo from "@/components/logos/beatsaver-logo"; diff --git a/src/components/player/score/score-info.tsx b/src/components/player/score/score-info.tsx index 469bad8..a2bc6ca 100644 --- a/src/components/player/score/score-info.tsx +++ b/src/components/player/score/score-info.tsx @@ -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 { getDifficultyFromScoreSaberDifficulty } from "@/common/scoresaber-utils"; import { songDifficultyToColor } from "@/common/song-utils"; diff --git a/src/components/player/score/score-rank-info.tsx b/src/components/player/score/score-rank-info.tsx index e93efca..bbc581e 100644 --- a/src/components/player/score/score-rank-info.tsx +++ b/src/components/player/score/score-rank-info.tsx @@ -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 { timeAgo } from "@/common/time-utils"; import { GlobeAmericasIcon } from "@heroicons/react/24/solid"; diff --git a/src/components/player/score/score-stats.tsx b/src/components/player/score/score-stats.tsx index 24c5f7a..7308da1 100644 --- a/src/components/player/score/score-stats.tsx +++ b/src/components/player/score/score-stats.tsx @@ -1,5 +1,5 @@ -import ScoreSaberLeaderboard from "@/common/data-fetcher/types/scoresaber/scoresaber-leaderboard"; -import ScoreSaberScore from "@/common/data-fetcher/types/scoresaber/scoresaber-score"; +import ScoreSaberLeaderboard from "@/common/service/types/scoresaber/scoresaber-leaderboard"; +import ScoreSaberScore from "@/common/service/types/scoresaber/scoresaber-score"; import { formatNumberWithCommas } from "@/common/number-utils"; import StatValue from "@/components/stat-value"; import { XMarkIcon } from "@heroicons/react/24/solid"; diff --git a/src/components/player/score/score.tsx b/src/components/player/score/score.tsx index 4f7ae89..5e3e3a3 100644 --- a/src/components/player/score/score.tsx +++ b/src/components/player/score/score.tsx @@ -1,7 +1,7 @@ "use client"; -import { beatsaverFetcher } from "@/common/data-fetcher/impl/beatsaver"; -import ScoreSaberPlayerScore from "@/common/data-fetcher/types/scoresaber/scoresaber-player-score"; +import { beatsaverService } from "@/common/service/impl/beatsaver"; +import ScoreSaberPlayerScore from "@/common/service/types/scoresaber/scoresaber-player-score"; import BeatSaverMap from "@/common/database/types/beatsaver-map"; import LeaderboardScores from "@/components/leaderboard/leaderboard-scores"; import { useCallback, useEffect, useState } from "react"; @@ -23,7 +23,7 @@ export default function Score({ playerScore }: Props) { const [isLeaderboardExpanded, setIsLeaderboardExpanded] = useState(false); const fetchBeatSaverData = useCallback(async () => { - const beatSaverMap = await beatsaverFetcher.lookupMap(leaderboard.songHash); + const beatSaverMap = await beatsaverService.lookupMap(leaderboard.songHash); setBeatSaverMap(beatSaverMap); }, [leaderboard.songHash]);