From 676a094f9bbd1ec3b10cdcb4d681937f873e339d Mon Sep 17 00:00:00 2001 From: large_r0dent Date: Thu, 18 Dec 2025 14:54:53 -0800 Subject: [PATCH 1/6] Support 30 minute streak offsets --- frontend/src/ts/modals/streak-hour-offset.ts | 38 +++++++++++--------- 1 file changed, 21 insertions(+), 17 deletions(-) diff --git a/frontend/src/ts/modals/streak-hour-offset.ts b/frontend/src/ts/modals/streak-hour-offset.ts index f2f9d90aa3c9..a5c375991a87 100644 --- a/frontend/src/ts/modals/streak-hour-offset.ts +++ b/frontend/src/ts/modals/streak-hour-offset.ts @@ -10,7 +10,7 @@ import { Snapshot } from "../constants/default-snapshot"; export function show(): void { if (!ConnectionState.get()) { - Notifications.add("You are offline", 0, { + Notifications.add("You are offline :(", 0, { duration: 2, }); return; @@ -24,7 +24,7 @@ export function show(): void { modalEl.querySelector(".preview")?.remove(); modalEl.querySelector("button")?.remove(); (modalEl.querySelector(".text") as HTMLElement).textContent = - "You have already set your streak hour offset."; + "You have already set your streak time offset."; } else { (modalEl.querySelector("input") as HTMLInputElement).value = "0"; updatePreview(); @@ -34,26 +34,24 @@ export function show(): void { } function updatePreview(): void { - const inputValue = parseInt( + const inputValue = parseFloat( // parse float to support fractional stuff modal.getModal().querySelector("input")?.value as string, - 10, ); const preview = modal.getModal().querySelector(".preview") as HTMLElement; const date = new Date(); - date.setUTCHours(0); - date.setUTCMinutes(0); - date.setUTCSeconds(0); - date.setUTCMilliseconds(0); + date.setUTCHours(0, 0, 0, 0); const newDate = new Date(); - newDate.setUTCHours(0); - newDate.setUTCMinutes(0); - newDate.setUTCSeconds(0); - newDate.setUTCMilliseconds(0); + newDate.setUTCHours(0, 0, 0, 0); - newDate.setHours(newDate.getHours() - -1 * inputValue); //idk why, but it only works when i subtract (so i have to negate inputValue) + const hours = Math.floor(inputValue); // integer part is hour offset + const minutes = (inputValue % 1) * 60; // fractional part is minutes + + // apply hr and min offsets + newDate.setUTCHours(newDate.getUTCHours() + hours); + newDate.setUTCMinutes(newDate.getUTCMinutes() + minutes); preview.innerHTML = `
Current local reset time:
${date.toLocaleTimeString()}
@@ -66,9 +64,8 @@ function hide(): void { } async function apply(): Promise { - const value = parseInt( + const value = parseFloat( // parse float again modal.getModal().querySelector("input")?.value as string, - 10, ); if (isNaN(value)) { @@ -76,8 +73,12 @@ async function apply(): Promise { return; } - if (value < -11 || value > 12) { - Notifications.add("Streak hour offset must be between -11 and 12", 0); + // 0.0 or 0.5 (assuming we only wanna allow 30 min offsets like in original issue) + if (value < -11 || value > 12 || (value % 1 !== 0 && value % 1 !== 0.5)) { + Notifications.add( + "Streak offset must be between -11 and 12. Times ending in .5 can be used for 30-minute increments.", + 0, + ); return; } @@ -87,11 +88,14 @@ async function apply(): Promise { body: { hourOffset: value }, }); Loader.hide(); + if (response.status !== 200) { Notifications.add("Failed to set streak hour offset", -1, { response }); } else { Notifications.add("Streak hour offset set", 1); const snap = getSnapshot() as Snapshot; + + // Save the new streak hour offset snap.streakHourOffset = value; setSnapshot(snap); hide(); From ced0876314690d8e0b1f0ae4c95dfbfe1fb5669c Mon Sep 17 00:00:00 2001 From: large_r0dent Date: Fri, 19 Dec 2025 11:29:08 -0800 Subject: [PATCH 2/6] Change hr offset step --- frontend/src/html/popups.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/src/html/popups.html b/frontend/src/html/popups.html index 686dd1306e99..e0000989d64b 100644 --- a/frontend/src/html/popups.html +++ b/frontend/src/html/popups.html @@ -1060,7 +1060,7 @@
You can only do this once! - + From dd4e5873ec28569c8fb3e6aadd76ec6ce39d9ceb Mon Sep 17 00:00:00 2001 From: large_r0dent Date: Fri, 19 Dec 2025 11:30:55 -0800 Subject: [PATCH 3/6] Remove comments --- frontend/src/ts/modals/streak-hour-offset.ts | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/frontend/src/ts/modals/streak-hour-offset.ts b/frontend/src/ts/modals/streak-hour-offset.ts index a5c375991a87..09470ae4d287 100644 --- a/frontend/src/ts/modals/streak-hour-offset.ts +++ b/frontend/src/ts/modals/streak-hour-offset.ts @@ -46,10 +46,9 @@ function updatePreview(): void { const newDate = new Date(); newDate.setUTCHours(0, 0, 0, 0); - const hours = Math.floor(inputValue); // integer part is hour offset - const minutes = (inputValue % 1) * 60; // fractional part is minutes + const hours = Math.floor(inputValue); + const minutes = (inputValue % 1) * 60; - // apply hr and min offsets newDate.setUTCHours(newDate.getUTCHours() + hours); newDate.setUTCMinutes(newDate.getUTCMinutes() + minutes); @@ -73,7 +72,6 @@ async function apply(): Promise { return; } - // 0.0 or 0.5 (assuming we only wanna allow 30 min offsets like in original issue) if (value < -11 || value > 12 || (value % 1 !== 0 && value % 1 !== 0.5)) { Notifications.add( "Streak offset must be between -11 and 12. Times ending in .5 can be used for 30-minute increments.", @@ -95,7 +93,6 @@ async function apply(): Promise { Notifications.add("Streak hour offset set", 1); const snap = getSnapshot() as Snapshot; - // Save the new streak hour offset snap.streakHourOffset = value; setSnapshot(snap); hide(); From 000d6439ebb6eab69aed48fe992b7bfe10f751b2 Mon Sep 17 00:00:00 2001 From: Jack Date: Sat, 20 Dec 2025 10:22:39 +0100 Subject: [PATCH 4/6] Update frontend/src/html/popups.html Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- frontend/src/html/popups.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/src/html/popups.html b/frontend/src/html/popups.html index e0000989d64b..e047df1cb636 100644 --- a/frontend/src/html/popups.html +++ b/frontend/src/html/popups.html @@ -1060,7 +1060,7 @@
You can only do this once! -
From 293705bd177801f5f1cebf8e4cc2c46852b79635 Mon Sep 17 00:00:00 2001 From: Miodec <13181393+Miodec@users.noreply.github.com> Date: Sat, 20 Dec 2025 09:25:12 +0000 Subject: [PATCH 5/6] fix formatting --- frontend/src/ts/modals/streak-hour-offset.ts | 6 ++++-- pnpm-lock.yaml | 13 +++++++------ 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/frontend/src/ts/modals/streak-hour-offset.ts b/frontend/src/ts/modals/streak-hour-offset.ts index 09470ae4d287..b0b35be6eeaf 100644 --- a/frontend/src/ts/modals/streak-hour-offset.ts +++ b/frontend/src/ts/modals/streak-hour-offset.ts @@ -34,7 +34,8 @@ export function show(): void { } function updatePreview(): void { - const inputValue = parseFloat( // parse float to support fractional stuff + const inputValue = parseFloat( + // parse float to support fractional stuff modal.getModal().querySelector("input")?.value as string, ); @@ -63,7 +64,8 @@ function hide(): void { } async function apply(): Promise { - const value = parseFloat( // parse float again + const value = parseFloat( + // parse float again modal.getModal().querySelector("input")?.value as string, ); diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 0577166a4cf9..0d8507283741 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -224,7 +224,7 @@ importers: version: 10.0.0 '@vitest/coverage-v8': specifier: 4.0.15 - version: 4.0.15(vitest@4.0.15(@opentelemetry/api@1.8.0)(@types/node@24.9.1)(happy-dom@20.0.10)(sass@1.70.0)(terser@5.44.1)(tsx@4.16.2)(yaml@2.8.1)) + version: 4.0.15(vitest@4.0.15(@types/node@24.9.1)(happy-dom@20.0.10)(sass@1.70.0)(terser@5.44.1)(tsx@4.16.2)(yaml@2.8.1)) concurrently: specifier: 8.2.2 version: 8.2.2 @@ -399,7 +399,7 @@ importers: version: 5.0.2 '@vitest/coverage-v8': specifier: 4.0.15 - version: 4.0.15(vitest@4.0.15(@opentelemetry/api@1.8.0)(@types/node@24.9.1)(happy-dom@20.0.10)(sass@1.70.0)(terser@5.44.1)(tsx@4.16.2)(yaml@2.8.1)) + version: 4.0.15(vitest@4.0.15(@types/node@24.9.1)(happy-dom@20.0.10)(sass@1.70.0)(terser@5.44.1)(tsx@4.16.2)(yaml@2.8.1)) autoprefixer: specifier: 10.4.20 version: 10.4.20(postcss@8.4.31) @@ -6234,6 +6234,7 @@ packages: keygrip@1.1.0: resolution: {integrity: sha512-iYSchDJ+liQ8iwbSI2QqsQOvqv58eJCEanyJPJi+Khyu8smkcKSFUCbPwzFcL7YVtZ6eONjqRX/38caJ7QjRAQ==} engines: {node: '>= 0.6'} + deprecated: Package no longer supported. Contact Support at https://www.npmjs.com/support for more info. keyv@4.5.4: resolution: {integrity: sha512-oxVHkHR/EJf2CNXnWxRLW6mg7JyCCUcG0DtEGmL2ctUo1PNTin1PUil+r/+4r5MpVgC/fn1kjsx7mjSujKqIpw==} @@ -12555,7 +12556,7 @@ snapshots: '@typescript-eslint/types': 7.18.0 eslint-visitor-keys: 3.4.3 - '@vitest/coverage-v8@4.0.15(vitest@4.0.15(@opentelemetry/api@1.8.0)(@types/node@24.9.1)(happy-dom@20.0.10)(sass@1.70.0)(terser@5.44.1)(tsx@4.16.2)(yaml@2.8.1))': + '@vitest/coverage-v8@4.0.15(vitest@4.0.15(@types/node@20.5.1)(happy-dom@20.0.10)(sass@1.70.0)(terser@5.44.1)(tsx@4.16.2)(yaml@2.8.1))': dependencies: '@bcoe/v8-coverage': 1.0.2 '@vitest/utils': 4.0.15 @@ -12568,11 +12569,11 @@ snapshots: obug: 2.1.1 std-env: 3.10.0 tinyrainbow: 3.0.3 - vitest: 4.0.15(@opentelemetry/api@1.8.0)(@types/node@24.9.1)(happy-dom@20.0.10)(sass@1.70.0)(terser@5.44.1)(tsx@4.16.2)(yaml@2.8.1) + vitest: 4.0.15(@types/node@20.5.1)(happy-dom@20.0.10)(sass@1.70.0)(terser@5.44.1)(tsx@4.16.2)(yaml@2.8.1) transitivePeerDependencies: - supports-color - '@vitest/coverage-v8@4.0.15(vitest@4.0.15(@types/node@20.5.1)(happy-dom@20.0.10)(sass@1.70.0)(terser@5.44.1)(tsx@4.16.2)(yaml@2.8.1))': + '@vitest/coverage-v8@4.0.15(vitest@4.0.15(@types/node@24.9.1)(happy-dom@20.0.10)(sass@1.70.0)(terser@5.44.1)(tsx@4.16.2)(yaml@2.8.1))': dependencies: '@bcoe/v8-coverage': 1.0.2 '@vitest/utils': 4.0.15 @@ -12585,7 +12586,7 @@ snapshots: obug: 2.1.1 std-env: 3.10.0 tinyrainbow: 3.0.3 - vitest: 4.0.15(@types/node@20.5.1)(happy-dom@20.0.10)(sass@1.70.0)(terser@5.44.1)(tsx@4.16.2)(yaml@2.8.1) + vitest: 4.0.15(@opentelemetry/api@1.8.0)(@types/node@24.9.1)(happy-dom@20.0.10)(sass@1.70.0)(terser@5.44.1)(tsx@4.16.2)(yaml@2.8.1) transitivePeerDependencies: - supports-color From db5ea94ee9cb015bcf002ea113641968acb131ac Mon Sep 17 00:00:00 2001 From: Miodec Date: Sat, 20 Dec 2025 10:28:01 +0100 Subject: [PATCH 6/6] pnpm i --- pnpm-lock.yaml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 0d8507283741..b8d97d249543 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -224,7 +224,7 @@ importers: version: 10.0.0 '@vitest/coverage-v8': specifier: 4.0.15 - version: 4.0.15(vitest@4.0.15(@types/node@24.9.1)(happy-dom@20.0.10)(sass@1.70.0)(terser@5.44.1)(tsx@4.16.2)(yaml@2.8.1)) + version: 4.0.15(vitest@4.0.15(@opentelemetry/api@1.8.0)(@types/node@24.9.1)(happy-dom@20.0.10)(sass@1.70.0)(terser@5.44.1)(tsx@4.16.2)(yaml@2.8.1)) concurrently: specifier: 8.2.2 version: 8.2.2 @@ -399,7 +399,7 @@ importers: version: 5.0.2 '@vitest/coverage-v8': specifier: 4.0.15 - version: 4.0.15(vitest@4.0.15(@types/node@24.9.1)(happy-dom@20.0.10)(sass@1.70.0)(terser@5.44.1)(tsx@4.16.2)(yaml@2.8.1)) + version: 4.0.15(vitest@4.0.15(@opentelemetry/api@1.8.0)(@types/node@24.9.1)(happy-dom@20.0.10)(sass@1.70.0)(terser@5.44.1)(tsx@4.16.2)(yaml@2.8.1)) autoprefixer: specifier: 10.4.20 version: 10.4.20(postcss@8.4.31) @@ -12556,7 +12556,7 @@ snapshots: '@typescript-eslint/types': 7.18.0 eslint-visitor-keys: 3.4.3 - '@vitest/coverage-v8@4.0.15(vitest@4.0.15(@types/node@20.5.1)(happy-dom@20.0.10)(sass@1.70.0)(terser@5.44.1)(tsx@4.16.2)(yaml@2.8.1))': + '@vitest/coverage-v8@4.0.15(vitest@4.0.15(@opentelemetry/api@1.8.0)(@types/node@24.9.1)(happy-dom@20.0.10)(sass@1.70.0)(terser@5.44.1)(tsx@4.16.2)(yaml@2.8.1))': dependencies: '@bcoe/v8-coverage': 1.0.2 '@vitest/utils': 4.0.15 @@ -12569,11 +12569,11 @@ snapshots: obug: 2.1.1 std-env: 3.10.0 tinyrainbow: 3.0.3 - vitest: 4.0.15(@types/node@20.5.1)(happy-dom@20.0.10)(sass@1.70.0)(terser@5.44.1)(tsx@4.16.2)(yaml@2.8.1) + vitest: 4.0.15(@opentelemetry/api@1.8.0)(@types/node@24.9.1)(happy-dom@20.0.10)(sass@1.70.0)(terser@5.44.1)(tsx@4.16.2)(yaml@2.8.1) transitivePeerDependencies: - supports-color - '@vitest/coverage-v8@4.0.15(vitest@4.0.15(@types/node@24.9.1)(happy-dom@20.0.10)(sass@1.70.0)(terser@5.44.1)(tsx@4.16.2)(yaml@2.8.1))': + '@vitest/coverage-v8@4.0.15(vitest@4.0.15(@types/node@20.5.1)(happy-dom@20.0.10)(sass@1.70.0)(terser@5.44.1)(tsx@4.16.2)(yaml@2.8.1))': dependencies: '@bcoe/v8-coverage': 1.0.2 '@vitest/utils': 4.0.15 @@ -12586,7 +12586,7 @@ snapshots: obug: 2.1.1 std-env: 3.10.0 tinyrainbow: 3.0.3 - vitest: 4.0.15(@opentelemetry/api@1.8.0)(@types/node@24.9.1)(happy-dom@20.0.10)(sass@1.70.0)(terser@5.44.1)(tsx@4.16.2)(yaml@2.8.1) + vitest: 4.0.15(@types/node@20.5.1)(happy-dom@20.0.10)(sass@1.70.0)(terser@5.44.1)(tsx@4.16.2)(yaml@2.8.1) transitivePeerDependencies: - supports-color