Skip to content

Commit

Permalink
Merge branch 'master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
pipinthedev authored Feb 3, 2025
2 parents cff67ea + 86cb17b commit 547acfa
Show file tree
Hide file tree
Showing 22 changed files with 700 additions and 66 deletions.
7 changes: 6 additions & 1 deletion backend/src/api/controllers/result.ts
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,12 @@ export async function addResult(

if (completedEvent.mode === "time" && completedEvent.mode2 === "60") {
void UserDAL.incrementBananas(uid, completedEvent.wpm);
if (isPb && user.discordId !== undefined && user.discordId !== "") {
if (
isPb &&
user.discordId !== undefined &&
user.discordId !== "" &&
user.lbOptOut !== true
) {
void GeorgeQueue.updateDiscordRole(user.discordId, completedEvent.wpm);
}
}
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/styles/media-queries-green.scss
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
.pageTest {
#result .wrapper .stats.morestats {
display: grid;
grid-template-columns: 1fr 1fr 1fr;
grid-template-columns: repeat(3, max-content);
grid-template-rows: 1fr 1fr;
}
#liveStatsTextTop,
Expand Down
5 changes: 5 additions & 0 deletions frontend/src/styles/media-queries-purple.scss
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,11 @@
.morestats {
justify-self: unset;
width: unset;

.group .bottom::after {
transform: none;
left: 0;
}
}
.buttons {
grid-template-columns: 1fr 1fr;
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/ts/elements/profile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ export async function update(
console.debug(hoverText);

if (streakOffset === undefined) {
hoverText += `\n\nIf the streak reset time doesn't line up with your timezone, you can change it in Settings > Danger zone > Update streak hour offset.`;
hoverText += `\n\nIf the streak reset time doesn't line up with your timezone, you can change it in Account Settings > Account > Set streak hour offset.`;
}
}
}
Expand Down
7 changes: 3 additions & 4 deletions frontend/src/ts/pages/login.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { InputIndicator } from "../elements/input-indicator";
import * as Skeleton from "../utils/skeleton";
import * as Misc from "../utils/misc";
import TypoList from "../utils/typo-list";
import { z } from "zod";

export function enableSignUpButton(): void {
$(".page.pageLogin .register.side button").prop("disabled", false);
Expand Down Expand Up @@ -81,16 +82,14 @@ const checkNameDebounced = debounce(1000, async () => {

const checkEmail = (): void => {
const email = $(".page.pageLogin .register.side .emailInput").val() as string;
const emailRegex =
/^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
const educationRegex =
/@.*(student|education|school|\.edu$|\.edu\.|\.ac\.|\.sch\.)/i;

const emailHasTypo = TypoList.some((typo) => {
return email.endsWith(typo);
});

if (emailRegex.test(email)) {
if (z.string().email().safeParse(email).success) {
if (emailHasTypo) {
emailIndicator.show(
"typo",
Expand All @@ -105,7 +104,7 @@ const checkEmail = (): void => {
emailIndicator.show("valid");
}
} else {
emailIndicator.show("invalid");
emailIndicator.show("invalid", "Please enter a valid email address.");
}

updateSignupButton();
Expand Down
20 changes: 12 additions & 8 deletions frontend/src/ts/test/result.ts
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,8 @@ export async function updateCrown(dontSave: boolean): Promise<void> {
let pbDiff = 0;
const canGetPb = await resultCanGetPb();

console.debug("Result can get PB:", canGetPb.value, canGetPb.reason ?? "");

if (canGetPb.value) {
const localPb = await DB.getLocalPB(
Config.mode,
Expand All @@ -406,10 +408,13 @@ export async function updateCrown(dontSave: boolean): Promise<void> {
);
const localPbWpm = localPb?.wpm ?? 0;
pbDiff = result.wpm - localPbWpm;
console.debug("Local PB", localPb, "diff", pbDiff);
if (pbDiff <= 0) {
hideCrown();
console.debug("Hiding crown");
} else {
//show half crown as the pb is not confirmed by the server
console.debug("Showing pending crown");
showCrown("pending");
updateCrownText(
"+" + Format.typingSpeed(pbDiff, { showDecimalPlaces: true })
Expand All @@ -428,14 +433,17 @@ export async function updateCrown(dontSave: boolean): Promise<void> {
);
const localPbWpm = localPb?.wpm ?? 0;
pbDiff = result.wpm - localPbWpm;
console.debug("Local PB", localPb, "diff", pbDiff);
if (pbDiff <= 0) {
// hideCrown();
console.debug("Showing warning crown");
showCrown("warning");
updateCrownText(
`This result is not eligible for a new PB (${canGetPb.reason})`,
true
);
} else {
console.debug("Showing ineligible crown");
showCrown("ineligible");
updateCrownText(
`You could've gotten a new PB (+${Format.typingSpeed(pbDiff, {
Expand All @@ -462,14 +470,10 @@ export function showErrorCrownIfNeeded(): void {
);
}

type CanGetPbObject =
| {
value: true;
}
| {
value: false;
reason: string;
};
type CanGetPbObject = {
value: boolean;
reason?: string;
};

async function resultCanGetPb(): Promise<CanGetPbObject> {
const funboxes = result.funbox?.split("#") ?? [];
Expand Down
6 changes: 5 additions & 1 deletion frontend/static/languages/_groups.json
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,7 @@
},
{
"name": "nepali",
"languages": ["nepali", "nepali_1k"]
"languages": ["nepali", "nepali_1k", "nepali_romanized"]
},
{
"name": "santali",
Expand Down Expand Up @@ -581,6 +581,10 @@
"occitan_10k"
]
},
{
"name": "zulu",
"languages": ["zulu"]
},
{
"name": "code",
"languages": [
Expand Down
2 changes: 2 additions & 0 deletions frontend/static/languages/_list.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
,"french_600k"
,"nepali"
,"nepali_1k"
,"nepali_romanized"
,"sanskrit"
,"sanskrit_roman"
,"santali"
Expand Down Expand Up @@ -315,6 +316,7 @@
,"occitan_5k"
,"occitan_10k"
,"bashkir"
,"zulu"
,"code_python"
,"code_python_1k"
,"code_python_2k"
Expand Down
3 changes: 0 additions & 3 deletions frontend/static/languages/english_25k.json
Original file line number Diff line number Diff line change
Expand Up @@ -7218,7 +7218,6 @@
"accomodate",
"prim",
"cilium",
"titty",
"feud",
"Aden",
"intercalation",
Expand Down Expand Up @@ -7319,7 +7318,6 @@
"downhill",
"awing",
"rotunda",
"tittie",
"plow",
"thewed",
"safari",
Expand Down Expand Up @@ -13100,7 +13098,6 @@
"draughts",
"grange",
"tenesmus",
"faeces",
"laminate",
"Maori",
"limo",
Expand Down
Loading

0 comments on commit 547acfa

Please sign in to comment.