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

Show live text instead of Unix epoch #7

Closed
wants to merge 1 commit into from
Closed
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
9 changes: 8 additions & 1 deletion src/components/snapshotCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,13 @@ export const SnapshotCard = ({
const imageWidth = width * 0.97;
const imageHeight = imageWidth * 0.75;

// ongoing events have end date of either '1/1/70' or '01/01/1970'
const endDate =
camEvent?.lastEventEnded.startsWith('1/1/70') ||
camEvent?.lastEventEnded.startsWith('01/01/1970')
? 'Current'
: camEvent?.lastEventEnded;

return (
<View className="self-center border border-accent dark:border-accent-dark relative rounded-lg">
<Image
Expand All @@ -39,7 +46,7 @@ export const SnapshotCard = ({
{!!camEvent.lastEventEnded && (
<Label>
<BaseText className="text-xs text-mutedForeground dark:text-mutedForeground-dark">
{camEvent.lastEventEnded}
{endDate}
</BaseText>
</Label>
)}
Expand Down
14 changes: 10 additions & 4 deletions src/screens/EventsScreen/components/EventDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,14 @@ export const EventDetails = ({camEvent}: {camEvent: FrigateEvent}) => {
// TODO: format minutes here too.
const eventDuration = Math.round(camEvent.end_time - camEvent.start_time);

const endTimeValue =
endDate.getFullYear() === 1970
? 'Current'
: endDate.toLocaleDateString() + ' @ ' + endDate.toLocaleTimeString();

const durationValue =
eventDuration < 0 ? 'Ongoing' : eventDuration + ' seconds';

return (
<BaseView className="flex-1">
<BaseText className="self-center text-lg mb-1">Event Details</BaseText>
Expand All @@ -30,13 +38,11 @@ export const EventDetails = ({camEvent}: {camEvent: FrigateEvent}) => {
</Row>
<Row>
<BaseText>End Time</BaseText>
<BaseText>
{endDate.toLocaleDateString() + ' @ ' + endDate.toLocaleTimeString()}
</BaseText>
<BaseText>{endTimeValue}</BaseText>
</Row>
<Row>
<BaseText>Event Duration</BaseText>
<BaseText>{eventDuration} seconds</BaseText>
<BaseText>{durationValue}</BaseText>
</Row>
<Row>
<BaseText>Object Label</BaseText>
Expand Down
Loading