Files
Homelab-manager/web/src/utils/problemsFirst.ts
T
bobbanandClaude Sonnet 5.5 b5384c1e03 Dashboard status banner, phone-friendly lists, and more command palette actions
- Dashboard: a banner that answers "is it fine?" (headline, root cause, kinds of problem, worst few); cards with a problem come first in their row
- Phone: Alerts, Updates and Inventory rows become compact cards, finger-sized buttons, Alerts drops its figure row; scanned inventory labels get an Edit button
- Command palette: acknowledge alerts, update a server, print a label, open hardware, "What depends on ...?"

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-18 22:00:19 +02:00

39 lines
911 B
TypeScript

import { useSyncExternalStore } from "react";
/**
* Whether dashboard cards that show a problem float to the top of their row (on by default). A preference of this browser only: the
* arrangement the person made with the arrows is untouched underneath and is what they edit.
*/
const KEY = "dashboard.problemsFirst";
const listeners = new Set<() => void>();
function read(): boolean {
try {
return localStorage.getItem(KEY) !== "0";
} catch {
return true;
}
}
let value = read();
export function setProblemsFirst(on: boolean): void {
value = on;
try {
localStorage.setItem(KEY, on ? "1" : "0");
} catch {
// a remembered choice is only a convenience
}
for (const l of listeners) l();
}
export function useProblemsFirst(): boolean {
return useSyncExternalStore(
(l) => {
listeners.add(l);
return () => listeners.delete(l);
},
() => value,
);
}