fix theme color
This commit is contained in:
parent
cb7143ed3d
commit
1e8a9b9a59
@ -10,6 +10,7 @@ import ScoreSaberPlayerScoreToken from "@ssr/common/types/token/scoresaber/score
|
|||||||
import { MessageBuilder, Webhook } from "discord-webhook-node";
|
import { MessageBuilder, Webhook } from "discord-webhook-node";
|
||||||
import { Config } from "../common/config";
|
import { Config } from "../common/config";
|
||||||
import { formatPp } from "@ssr/common/utils/number-utils";
|
import { formatPp } from "@ssr/common/utils/number-utils";
|
||||||
|
import { isProduction } from "@ssr/common/utils/utils";
|
||||||
|
|
||||||
export class PlayerService {
|
export class PlayerService {
|
||||||
/**
|
/**
|
||||||
@ -40,6 +41,8 @@ export class PlayerService {
|
|||||||
player.trackedSince = new Date();
|
player.trackedSince = new Date();
|
||||||
await this.seedPlayerHistory(player, playerToken);
|
await this.seedPlayerHistory(player, playerToken);
|
||||||
|
|
||||||
|
// Only notify in production
|
||||||
|
if (isProduction()) {
|
||||||
const hook = new Webhook({
|
const hook = new Webhook({
|
||||||
url: Config.trackedPlayerWebhook,
|
url: Config.trackedPlayerWebhook,
|
||||||
});
|
});
|
||||||
@ -53,6 +56,7 @@ export class PlayerService {
|
|||||||
embed.setThumbnail(playerToken.profilePicture);
|
embed.setThumbnail(playerToken.profilePicture);
|
||||||
embed.setColor("#00ff00");
|
embed.setColor("#00ff00");
|
||||||
await hook.send(embed);
|
await hook.send(embed);
|
||||||
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
const message = `Failed to create player document for "${id}"`;
|
const message = `Failed to create player document for "${id}"`;
|
||||||
console.log(message, err);
|
console.log(message, err);
|
||||||
|
@ -4,9 +4,15 @@ import ScoreSaberPlayerScoreToken from "@ssr/common/types/token/scoresaber/score
|
|||||||
import { MessageBuilder, Webhook } from "discord-webhook-node";
|
import { MessageBuilder, Webhook } from "discord-webhook-node";
|
||||||
import { Config } from "../common/config";
|
import { Config } from "../common/config";
|
||||||
import { formatPp } from "@ssr/common/utils/number-utils";
|
import { formatPp } from "@ssr/common/utils/number-utils";
|
||||||
|
import { isProduction } from "@ssr/common/utils/utils";
|
||||||
|
|
||||||
export class ScoreService {
|
export class ScoreService {
|
||||||
public static async notifyNumberOne(playerScore: ScoreSaberPlayerScoreToken) {
|
public static async notifyNumberOne(playerScore: ScoreSaberPlayerScoreToken) {
|
||||||
|
// Only notify in production
|
||||||
|
if (!isProduction()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const { score, leaderboard } = playerScore;
|
const { score, leaderboard } = playerScore;
|
||||||
const player = score.leaderboardPlayerInfo;
|
const player = score.leaderboardPlayerInfo;
|
||||||
|
|
||||||
|
@ -118,7 +118,7 @@ export async function generateViewport(props: Props): Promise<Viewport> {
|
|||||||
|
|
||||||
const color = await getAverageColor(player.avatar);
|
const color = await getAverageColor(player.avatar);
|
||||||
return {
|
return {
|
||||||
themeColor: color.hex,
|
themeColor: color.color,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -20,10 +20,10 @@ export function getImageUrl(originalUrl: string) {
|
|||||||
*/
|
*/
|
||||||
export const getAverageColor = async (src: string) => {
|
export const getAverageColor = async (src: string) => {
|
||||||
try {
|
try {
|
||||||
return await ky.get<{ hex: string }>(`${config.siteApi}/image/averagecolor/${encodeURIComponent(src)}`).json();
|
return await ky.get<{ color: string }>(`${config.siteApi}/image/averagecolor/${encodeURIComponent(src)}`).json();
|
||||||
} catch {
|
} catch {
|
||||||
return {
|
return {
|
||||||
hex: Colors.primary,
|
color: Colors.primary,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -32,7 +32,9 @@ export function ApiHealth() {
|
|||||||
if (previousOnlineStatus.current !== online) {
|
if (previousOnlineStatus.current !== online) {
|
||||||
toast({
|
toast({
|
||||||
title: `The API is now ${online ? "Online" : "Offline"}!`,
|
title: `The API is now ${online ? "Online" : "Offline"}!`,
|
||||||
description: online ? "The API has recovered connectivity." : "The API has lost connectivity.",
|
description: online
|
||||||
|
? "The API has recovered connectivity."
|
||||||
|
: "The API has lost connectivity, some data may be unavailable.",
|
||||||
variant: online ? "success" : "destructive",
|
variant: online ? "success" : "destructive",
|
||||||
duration: 10_000, // 10 seconds
|
duration: 10_000, // 10 seconds
|
||||||
});
|
});
|
||||||
|
Reference in New Issue
Block a user