This commit is contained in:
parent
ba0a406eb4
commit
73b7d17597
@ -1,37 +0,0 @@
|
|||||||
import BeatSaverMap from "@/common/database/types/beatsaver-map";
|
|
||||||
import { db } from "@/common/database/database";
|
|
||||||
import { beatsaverService } from "@ssr/common/service/impl/beatsaver";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the map that match the query.
|
|
||||||
*
|
|
||||||
* @param query the query to search for
|
|
||||||
* @returns the map that match the query, or undefined if no map were found
|
|
||||||
*/
|
|
||||||
export async function lookupBeatSaverMap(query: string): Promise<BeatSaverMap | undefined> {
|
|
||||||
let map = await db.beatSaverMaps.get(query);
|
|
||||||
// The map is cached
|
|
||||||
if (map != undefined) {
|
|
||||||
return map;
|
|
||||||
}
|
|
||||||
|
|
||||||
const response = await beatsaverService.lookupMap(query);
|
|
||||||
// Map not found
|
|
||||||
if (response == undefined) {
|
|
||||||
return undefined;
|
|
||||||
}
|
|
||||||
|
|
||||||
const bsr = response.id;
|
|
||||||
if (bsr == undefined) {
|
|
||||||
return undefined;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Save map the the db
|
|
||||||
await db.beatSaverMaps.add({
|
|
||||||
hash: query,
|
|
||||||
bsr: bsr,
|
|
||||||
fullData: response,
|
|
||||||
});
|
|
||||||
map = await db.beatSaverMaps.get(query);
|
|
||||||
return map;
|
|
||||||
}
|
|
@ -1,4 +1,4 @@
|
|||||||
import { PlayerHistory } from "@ssr/common/types/player/player-history";
|
import { PlayerHistory } from "@ssr/common/player/player-history";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets a value from an {@link PlayerHistory}
|
* Gets a value from an {@link PlayerHistory}
|
||||||
|
@ -5,7 +5,7 @@ import ky from "ky";
|
|||||||
import Tooltip from "@/components/tooltip";
|
import Tooltip from "@/components/tooltip";
|
||||||
import { InformationCircleIcon } from "@heroicons/react/16/solid";
|
import { InformationCircleIcon } from "@heroicons/react/16/solid";
|
||||||
import { formatNumberWithCommas } from "@ssr/common/utils/number-utils";
|
import { formatNumberWithCommas } from "@ssr/common/utils/number-utils";
|
||||||
import { PlayerTrackedSince } from "@ssr/common/types/player/player-tracked-since";
|
import { PlayerTrackedSince } from "@ssr/common/player/player-tracked-since";
|
||||||
import ScoreSaberPlayer from "@ssr/common/player/impl/scoresaber-player";
|
import ScoreSaberPlayer from "@ssr/common/player/impl/scoresaber-player";
|
||||||
import { Config } from "@ssr/common/config";
|
import { Config } from "@ssr/common/config";
|
||||||
|
|
||||||
|
@ -7,6 +7,8 @@ import { parseDate } from "@ssr/common/utils/time-utils";
|
|||||||
import Link from "next/link";
|
import Link from "next/link";
|
||||||
import useWebSocket, { ReadyState } from "react-use-websocket";
|
import useWebSocket, { ReadyState } from "react-use-websocket";
|
||||||
import { ScoreSaberWebsocketMessageToken } from "@ssr/common/types/token/scoresaber/websocket/scoresaber-websocket-message";
|
import { ScoreSaberWebsocketMessageToken } from "@ssr/common/types/token/scoresaber/websocket/scoresaber-websocket-message";
|
||||||
|
import { getScoreSaberScoreFromToken } from "@ssr/common/score/impl/scoresaber-score";
|
||||||
|
import { getScoreSaberLeaderboardFromToken } from "@ssr/common/leaderboard/impl/scoresaber-leaderboard";
|
||||||
|
|
||||||
export default function ScoreFeed() {
|
export default function ScoreFeed() {
|
||||||
const { readyState, lastJsonMessage } = useWebSocket<ScoreSaberWebsocketMessageToken>("wss://scoresaber.com/ws");
|
const { readyState, lastJsonMessage } = useWebSocket<ScoreSaberWebsocketMessageToken>("wss://scoresaber.com/ws");
|
||||||
@ -49,7 +51,8 @@ export default function ScoreFeed() {
|
|||||||
</Link>
|
</Link>
|
||||||
</p>
|
</p>
|
||||||
<Score
|
<Score
|
||||||
score={score}
|
score={getScoreSaberScoreFromToken(score.score)}
|
||||||
|
leaderboard={getScoreSaberLeaderboardFromToken(score.leaderboard)}
|
||||||
settings={{
|
settings={{
|
||||||
noScoreButtons: true,
|
noScoreButtons: true,
|
||||||
}}
|
}}
|
||||||
|
@ -5,7 +5,7 @@ import Image from "next/image";
|
|||||||
import { songDifficultyToColor } from "@/common/song-utils";
|
import { songDifficultyToColor } from "@/common/song-utils";
|
||||||
import Link from "next/link";
|
import Link from "next/link";
|
||||||
import ScoreSaberLeaderboard from "@ssr/common/leaderboard/impl/scoresaber-leaderboard";
|
import ScoreSaberLeaderboard from "@ssr/common/leaderboard/impl/scoresaber-leaderboard";
|
||||||
import { BeatSaverMap } from "@ssr/common/model/beatsaver-map";
|
import { BeatSaverMap } from "@ssr/common/model/beatsaver/beatsaver-map";
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
leaderboard: ScoreSaberLeaderboard;
|
leaderboard: ScoreSaberLeaderboard;
|
||||||
@ -14,7 +14,7 @@ type Props = {
|
|||||||
|
|
||||||
export default function ScoreSongInfo({ leaderboard, beatSaverMap }: Props) {
|
export default function ScoreSongInfo({ leaderboard, beatSaverMap }: Props) {
|
||||||
const mappersProfile =
|
const mappersProfile =
|
||||||
beatSaverMap != undefined ? `https://beatsaver.com/profile/${beatSaverMap?.author.authorId}` : undefined;
|
beatSaverMap != undefined ? `https://beatsaver.com/profile/${beatSaverMap?.author.id}` : undefined;
|
||||||
|
|
||||||
const starCount = leaderboard.stars;
|
const starCount = leaderboard.stars;
|
||||||
const difficulty = leaderboard.difficulty;
|
const difficulty = leaderboard.difficulty;
|
||||||
|
Reference in New Issue
Block a user