Skip to content

Commit

Permalink
Bugfixes (#14587)
Browse files Browse the repository at this point in the history
* Ensure review and search item mobile pages reopen correctly

* disable pan/pinch/zoom when native browser video controls are displayed

* report 0 for storage usage when api returns null
  • Loading branch information
hawkeye217 authored Oct 25, 2024
1 parent 2d27e72 commit 4dadf6d
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 23 deletions.
2 changes: 1 addition & 1 deletion web/src/components/graph/CombinedStorageGraph.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ export function CombinedStorageGraph({
</Popover>
)}
</TableCell>
<TableCell>{getUnitSize(item.usage)}</TableCell>
<TableCell>{getUnitSize(item.usage ?? 0)}</TableCell>
<TableCell>{item.data[0].toFixed(2)}%</TableCell>
<TableCell>
{item.name === "Unused"
Expand Down
8 changes: 7 additions & 1 deletion web/src/components/mobile/MobilePage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,13 @@ export function MobilePage({
const [uncontrolledOpen, setUncontrolledOpen] = useState(false);

const open = controlledOpen ?? uncontrolledOpen;
const setOpen = onOpenChange ?? setUncontrolledOpen;
const setOpen = (value: boolean) => {
if (onOpenChange) {
onOpenChange(value);
} else {
setUncontrolledOpen(value);
}
};

return (
<MobilePageContext.Provider value={{ open, onOpenChange: setOpen }}>
Expand Down
31 changes: 19 additions & 12 deletions web/src/components/overlay/detail/ReviewDetailDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { getIconForLabel } from "@/utils/iconUtil";
import { useApiHost } from "@/api";
import { ReviewDetailPaneType, ReviewSegment } from "@/types/review";
import { Event } from "@/types/event";
import { useEffect, useMemo, useRef, useState } from "react";
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
import { cn } from "@/lib/utils";
import { FrigatePlusDialog } from "../dialog/FrigatePlusDialog";
import ObjectLifecycle from "./ObjectLifecycle";
Expand Down Expand Up @@ -91,6 +91,22 @@ export default function ReviewDetailDialog({
review != undefined,
);

const handleOpenChange = useCallback(
(open: boolean) => {
setIsOpen(open);
if (!open) {
// short timeout to allow the mobile page animation
// to complete before updating the state
setTimeout(() => {
setReview(undefined);
setSelectedEvent(undefined);
setPane("overview");
}, 300);
}
},
[setReview, setIsOpen],
);

useEffect(() => {
setIsOpen(review != undefined);
// we know that these deps are correct
Expand All @@ -109,16 +125,7 @@ export default function ReviewDetailDialog({

return (
<>
<Overlay
open={isOpen ?? false}
onOpenChange={(open) => {
if (!open) {
setReview(undefined);
setSelectedEvent(undefined);
setPane("overview");
}
}}
>
<Overlay open={isOpen ?? false} onOpenChange={handleOpenChange}>
<FrigatePlusDialog
upload={upload}
onClose={() => setUpload(undefined)}
Expand All @@ -140,7 +147,7 @@ export default function ReviewDetailDialog({
>
<span tabIndex={0} className="sr-only" />
{pane == "overview" && (
<Header className="justify-center" onClose={() => setIsOpen(false)}>
<Header className="justify-center">
<Title>Review Item Details</Title>
<Description className="sr-only">Review item details</Description>
<div
Expand Down
25 changes: 16 additions & 9 deletions web/src/components/overlay/detail/SearchDetailDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,20 @@ export default function SearchDetailDialog({

const [isOpen, setIsOpen] = useState(search != undefined);

const handleOpenChange = useCallback(
(open: boolean) => {
setIsOpen(open);
if (!open) {
// short timeout to allow the mobile page animation
// to complete before updating the state
setTimeout(() => {
setSearch(undefined);
}, 300);
}
},
[setSearch],
);

useEffect(() => {
if (search) {
setIsOpen(search != undefined);
Expand Down Expand Up @@ -158,14 +172,7 @@ export default function SearchDetailDialog({
const Description = isDesktop ? DialogDescription : MobilePageDescription;

return (
<Overlay
open={isOpen}
onOpenChange={() => {
if (search) {
setSearch(undefined);
}
}}
>
<Overlay open={isOpen} onOpenChange={handleOpenChange}>
<Content
className={cn(
"scrollbar-container overflow-y-auto",
Expand All @@ -174,7 +181,7 @@ export default function SearchDetailDialog({
isMobile && "px-4",
)}
>
<Header onClose={() => setIsOpen(false)}>
<Header>
<Title>Tracked Object Details</Title>
<Description className="sr-only">Tracked object details</Description>
</Header>
Expand Down
1 change: 1 addition & 0 deletions web/src/components/player/HlsVideoPlayer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ export default function HlsVideoPlayer({
minScale={1.0}
wheel={{ smoothStep: 0.005 }}
onZoom={(zoom) => setZoomScale(zoom.state.scale)}
disabled={!frigateControls}
>
{frigateControls && (
<VideoControls
Expand Down

0 comments on commit 4dadf6d

Please sign in to comment.