Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UI Fixes #13703

Merged
merged 2 commits into from
Sep 12, 2024
Merged

UI Fixes #13703

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions web/src/components/card/AnimatedEventCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -91,13 +91,17 @@ export function AnimatedEventCard({
const [alertVideos] = usePersistence("alertVideos", true);

const aspectRatio = useMemo(() => {
if (!config || !Object.keys(config.cameras).includes(event.camera)) {
if (
!config ||
!alertVideos ||
!Object.keys(config.cameras).includes(event.camera)
) {
return 16 / 9;
}

const detect = config.cameras[event.camera].detect;
return detect.width / detect.height;
}, [config, event]);
}, [alertVideos, config, event]);

return (
<Tooltip>
Expand Down
1 change: 1 addition & 0 deletions web/src/components/card/ReviewCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ export default function ReviewCard({
const formattedDate = useFormattedTimestamp(
event.start_time,
config?.ui.time_format == "24hour" ? "%H:%M" : "%I:%M %p",
config?.ui.timezone,
);
const isSelected = useMemo(
() =>
Expand Down
1 change: 1 addition & 0 deletions web/src/components/card/SearchThumbnail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ export default function SearchThumbnail({
const formattedDate = useFormattedTimestamp(
searchResult.start_time,
config?.ui.time_format == "24hour" ? "%b %-d, %H:%M" : "%b %-d, %I:%M %p",
config?.ui.timezone,
);

return (
Expand Down
1 change: 1 addition & 0 deletions web/src/components/overlay/detail/ReviewDetailDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ export default function ReviewDetailDialog({
config?.ui.time_format == "24hour"
? "%b %-d %Y, %H:%M"
: "%b %-d %Y, %I:%M %p",
config?.ui.timezone,
);

// content
Expand Down
1 change: 1 addition & 0 deletions web/src/components/overlay/detail/SearchDetailDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,7 @@ function ObjectDetailsTab({
config?.ui.time_format == "24hour"
? "%b %-d %Y, %H:%M"
: "%b %-d %Y, %I:%M %p",
config?.ui.timezone,
);

const score = useMemo(() => {
Expand Down
1 change: 1 addition & 0 deletions web/src/components/player/PreviewThumbnailPlayer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ export default function PreviewThumbnailPlayer({
const formattedDate = useFormattedTimestamp(
review.start_time,
config?.ui.time_format == "24hour" ? "%b %-d, %H:%M" : "%b %-d, %I:%M %p",
config?.ui?.timezone,
);

return (
Expand Down
9 changes: 7 additions & 2 deletions web/src/hooks/use-date-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,17 @@ import { FrigateConfig } from "@/types/frigateConfig";
import { formatUnixTimestampToDateTime } from "@/utils/dateUtil";
import { useMemo } from "react";

export function useFormattedTimestamp(timestamp: number, format: string) {
export function useFormattedTimestamp(
timestamp: number,
format: string,
timezone?: string,
) {
const formattedTimestamp = useMemo(() => {
return formatUnixTimestampToDateTime(timestamp, {
timezone,
strftime_fmt: format,
});
}, [format, timestamp]);
}, [format, timestamp, timezone]);

return formattedTimestamp;
}
Expand Down