summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorYuval Adam <_@yuv.al>2024-09-23 14:32:51 +0200
committerYuval Adam <_@yuv.al>2024-09-23 14:32:51 +0200
commitd5cf0f5f273fc5518582fd0cd6b42bafdd6764eb (patch)
treed27e94f72cac099a52f24be6840d6a9cb1b442c1 /app
parentf5c1663447e0b1c564367f14d0b8c3b2cb39d65e (diff)
Cleanup playback impl
Diffstat (limited to 'app')
-rw-r--r--app/components/Geshem.tsx30
1 files changed, 18 insertions, 12 deletions
diff --git a/app/components/Geshem.tsx b/app/components/Geshem.tsx
index 9f6e5f4..ba67b34 100644
--- a/app/components/Geshem.tsx
+++ b/app/components/Geshem.tsx
@@ -23,18 +23,24 @@ export function Geshem() {
.then(setImages);
const buildPlayback = async () => {
- const date = fragment;
- const hours = Array.from(Array(PLAYBACK_HOURS).keys()).map(
- h => `${String(h).padStart(2, "0")}`
- );
- const minutes = Array.from(Array(6).keys()).map(
- m => `${String(m * 10).padStart(2, "0")}`
- );
- const paths = hours.reduce<string[]>(
- (acc, h) =>
- acc.concat(minutes.map(m => `imgs/${date}/${h}${m}/280.png`)),
- []
- );
+ if (fragment === undefined) return;
+ const date = fragment.slice(0, 8);
+ const startHour = parseInt(fragment.slice(8, 10)) || 9;
+ const startMinute = parseInt(fragment.slice(10, 12)) || 0;
+
+ const generateTimeSlots = (start: number): string[] => {
+ const slots = [];
+ for (let i = 0; i < PLAYBACK_HOURS * 6; i++) {
+ const minutes = (start + i * 10) % 60;
+ const hours = (startHour + Math.floor((start + i * 10) / 60)) % 24;
+ slots.push(`${String(hours).padStart(2, "0")}${String(minutes).padStart(2, "0")}`);
+ }
+ return slots;
+ };
+
+ const timeSlots = generateTimeSlots(startMinute);
+ const paths = timeSlots.map(slot => `imgs/${date}/${slot}/280.png`);
+
setImages(paths);
};