Fixed Device "Last Seen" Logic and Watchdog Behavior

This commit is contained in:
2025-09-02 21:06:39 -06:00
parent 5c96bd9027
commit 4db6414da4
4 changed files with 88 additions and 8 deletions

View File

@@ -34,10 +34,10 @@ export default function DeviceDetails({ device, onBack }) {
const tsSec = device?.lastSeen;
if (!tsSec) return "Offline";
const now = Date.now() / 1000;
return now - tsSec <= 15 ? "Online" : "Offline";
return now - tsSec <= 120 ? "Online" : "Offline";
});
const statusFromHeartbeat = (tsSec, offlineAfter = 15) => {
const statusFromHeartbeat = (tsSec, offlineAfter = 120) => {
if (!tsSec) return "Offline";
const now = Date.now() / 1000;
return now - tsSec <= offlineAfter ? "Online" : "Offline";
@@ -45,7 +45,7 @@ export default function DeviceDetails({ device, onBack }) {
const statusColor = (s) => (s === "Online" ? "#00d18c" : "#ff4f4f");
const formatLastSeen = (tsSec, offlineAfter = 15) => {
const formatLastSeen = (tsSec, offlineAfter = 120) => {
if (!tsSec) return "unknown";
const now = Date.now() / 1000;
if (now - tsSec <= offlineAfter) return "Currently Online";

View File

@@ -18,7 +18,7 @@ import {
import MoreVertIcon from "@mui/icons-material/MoreVert";
import { DeleteDeviceDialog } from "../Dialogs.jsx";
function formatLastSeen(tsSec, offlineAfter = 15) {
function formatLastSeen(tsSec, offlineAfter = 120) {
if (!tsSec) return "unknown";
const now = Date.now() / 1000;
if (now - tsSec <= offlineAfter) return "Currently Online";
@@ -35,7 +35,7 @@ function formatLastSeen(tsSec, offlineAfter = 15) {
return `${date} @ ${time}`;
}
function statusFromHeartbeat(tsSec, offlineAfter = 15) {
function statusFromHeartbeat(tsSec, offlineAfter = 120) {
if (!tsSec) return "Offline";
const now = Date.now() / 1000;
return now - tsSec <= offlineAfter ? "Online" : "Offline";