Skip to content

Commit

Permalink
add shortcut and query for fullscreen in live view (#12924)
Browse files Browse the repository at this point in the history
* add shortcut and query for live view

* Update web/src/views/live/LiveDashboardView.tsx

* Update web/src/views/live/LiveDashboardView.tsx

Co-authored-by: Nicolas Mowen <nickmowen213@gmail.com>

* Apply suggestions from code review

Co-authored-by: Nicolas Mowen <nickmowen213@gmail.com>

* Update LiveDashboardView.tsx

---------

Co-authored-by: Nicolas Mowen <nickmowen213@gmail.com>
  • Loading branch information
stavros-k and NickM-27 committed Aug 30, 2024
1 parent 940c12d commit d3259c4
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions web/src/views/live/LiveDashboardView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ import { cn } from "@/lib/utils";
import { LivePlayerError, LivePlayerMode } from "@/types/live";
import { FaCompress, FaExpand } from "react-icons/fa";
import { useResizeObserver } from "@/hooks/resize-observer";
import useKeyboardListener, {
KeyModifiers,
} from "@/hooks/use-keyboard-listener";

type LiveDashboardViewProps = {
cameras: CameraConfig[];
Expand Down Expand Up @@ -247,6 +250,23 @@ export default function LiveDashboardView({
[setPreferredLiveModes],
);

const onKeyboardShortcut = useCallback(
(key: string, modifiers: KeyModifiers) => {
if (!modifiers.down) {
return;
}

switch (key) {
case "f":
toggleFullscreen();
break;
}
},
[toggleFullscreen],
);

useKeyboardListener(["f"], onKeyboardShortcut);

return (
<div
className="scrollbar-container size-full overflow-y-auto px-1 pt-2 md:p-2"
Expand Down

0 comments on commit d3259c4

Please sign in to comment.