WebUI Improvements and fixes (#9613)

* Show toast instead of text for success and errors

* Show correct times

* Start playing next hour when current hour ends

* Fix refreshing camera image

* Fix timeline
This commit is contained in:
Nicolas Mowen
2024-02-05 16:54:08 -07:00
committed by GitHub
parent 3df8b5829c
commit f4310862aa
10 changed files with 435 additions and 57 deletions

View File

@@ -284,8 +284,13 @@ export function getRangeForTimestamp(timestamp: number) {
date.setHours(date.getHours() + 1);
// ensure not to go past current time
const end = Math.min(new Date().getTime() / 1000, date.getTime() / 1000);
return { start, end };
return { start, end: endOfHourOrCurrentTime(date.getTime() / 1000) };
}
export function endOfHourOrCurrentTime(timestamp: number) {
const now = new Date();
now.setMilliseconds(0);
return Math.min(timestamp, now.getTime() / 1000);
}
export function isCurrentHour(timestamp: number) {

View File

@@ -1,3 +1,5 @@
import { endOfHourOrCurrentTime } from "./dateUtil";
// group history cards by 120 seconds of activity
const GROUP_SECONDS = 120;
@@ -169,7 +171,7 @@ export function getTimelineHoursForDay(
break;
}
end = startDay.getTime() / 1000;
end = endOfHourOrCurrentTime(startDay.getTime() / 1000);
const hour = Object.values(day).find((cards) => {
const card = Object.values(cards)[0];
if (card == undefined || card.time < start || card.time > end) {