diff --git a/frontend/src/html/popups.html b/frontend/src/html/popups.html
index 686dd1306e99..e047df1cb636 100644
--- a/frontend/src/html/popups.html
+++ b/frontend/src/html/popups.html
@@ -1060,7 +1060,7 @@
You can only do this once!
-
+
diff --git a/frontend/src/ts/modals/streak-hour-offset.ts b/frontend/src/ts/modals/streak-hour-offset.ts
index f2f9d90aa3c9..b0b35be6eeaf 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);
+ const minutes = (inputValue % 1) * 60;
+
+ newDate.setUTCHours(newDate.getUTCHours() + hours);
+ newDate.setUTCMinutes(newDate.getUTCMinutes() + minutes);
preview.innerHTML = `
Current local reset time:
${date.toLocaleTimeString()}
@@ -66,9 +64,9 @@ 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 +74,11 @@ async function apply(): Promise {
return;
}
- if (value < -11 || value > 12) {
- Notifications.add("Streak hour offset must be between -11 and 12", 0);
+ 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,13 @@ 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;
+
snap.streakHourOffset = value;
setSnapshot(snap);
hide();
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 17e59006f00c..d6a64f7f31de 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -6231,6 +6231,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==}