Add rotation to the wall display: overview, what needs attention, and one page per group of integrations
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
fa7cc282bb
commit
d980c12a04
8 files changed
+398
-4
No files matched your search
@@ -0,0 +1,41 @@
|
||||
import { useCallback } from "react";
|
||||
import { useSearchParams } from "react-router-dom";
|
||||
import { rotateSeconds } from "../utils/wallPages";
|
||||
|
||||
const KEY = "wall.rotate";
|
||||
|
||||
function stored(): string | null {
|
||||
try {
|
||||
return localStorage.getItem(KEY);
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* How the wall display rotates: how many seconds each page stays, or null for the overview alone. It lives in the address (`?rotate=30`),
|
||||
* so a TV's bookmark carries it, and this browser remembers the last choice made on the board itself.
|
||||
*/
|
||||
export function useWallRotation() {
|
||||
const [params, setParams] = useSearchParams();
|
||||
const seconds = rotateSeconds(params.get("rotate"), stored());
|
||||
const setSeconds = useCallback(
|
||||
(next: number | null) => {
|
||||
try {
|
||||
localStorage.setItem(KEY, next === null ? "off" : String(next));
|
||||
} catch {
|
||||
/* a private window: the address alone carries it */
|
||||
}
|
||||
setParams(
|
||||
(prev) => {
|
||||
const p = new URLSearchParams(prev);
|
||||
p.set("rotate", next === null ? "off" : String(next));
|
||||
return p;
|
||||
},
|
||||
{ replace: true },
|
||||
);
|
||||
},
|
||||
[setParams],
|
||||
);
|
||||
return { seconds, setSeconds };
|
||||
}
|
||||
Reference in new issue
Block a user