impr(reporting): dont allow reporting for suspected cheating if user has opted out of leaderboards

This commit is contained in:
Miodec 2024-02-05 15:01:04 +01:00
parent fed310ee9c
commit 7326ff0985

View file

@ -9,15 +9,18 @@ const wrapperId = "userReportPopupWrapper";
interface State {
userUid?: string;
lbOptOut?: boolean;
}
const state: State = {
userUid: undefined,
lbOptOut: undefined,
};
interface ShowOptions {
uid: string;
name: string;
lbOptOut: boolean;
}
export async function show(options: ShowOptions): Promise<void> {
@ -30,6 +33,7 @@ export async function show(options: ShowOptions): Promise<void> {
const { name } = options;
state.userUid = options.uid;
state.lbOptOut = options.lbOptOut;
$("#userReportPopup .user").text(name);
$("#userReportPopup .reason").val("Inappropriate name");
@ -85,6 +89,16 @@ async function submitReport(): Promise<void> {
return Notifications.add("Please provide a comment");
}
if (reason === "Suspected cheating" && state.lbOptOut) {
return Notifications.add(
"You cannot report this user for suspected cheating as they have opted out of the leaderboard.",
0,
{
duration: 10,
}
);
}
const characterDifference = comment.length - 250;
if (characterDifference > 0) {
return Notifications.add(