fix: Verification in provisioning fixed
This commit is contained in:
@@ -749,7 +749,7 @@ function StepVerify({ device, onVerified }) {
|
|||||||
setTimedOut(false);
|
setTimedOut(false);
|
||||||
setError("");
|
setError("");
|
||||||
|
|
||||||
const startTime = new Date().toISOString();
|
const startTime = Date.now();
|
||||||
|
|
||||||
intervalRef.current = setInterval(async () => {
|
intervalRef.current = setInterval(async () => {
|
||||||
try {
|
try {
|
||||||
@@ -761,7 +761,12 @@ function StepVerify({ device, onVerified }) {
|
|||||||
if (hbData.heartbeats && hbData.heartbeats.length > 0) {
|
if (hbData.heartbeats && hbData.heartbeats.length > 0) {
|
||||||
const latest = hbData.heartbeats[0];
|
const latest = hbData.heartbeats[0];
|
||||||
const receivedAt = latest.received_at;
|
const receivedAt = latest.received_at;
|
||||||
if (receivedAt && receivedAt > startTime) {
|
// SQLite stores datetime as "YYYY-MM-DD HH:MM:SS" (UTC, no T/Z suffix).
|
||||||
|
// Replace the space with T and append Z so Date.parse() treats it as UTC.
|
||||||
|
const receivedMs = receivedAt
|
||||||
|
? Date.parse(receivedAt.replace(" ", "T") + "Z")
|
||||||
|
: NaN;
|
||||||
|
if (!isNaN(receivedMs) && receivedMs > startTime) {
|
||||||
clearInterval(intervalRef.current);
|
clearInterval(intervalRef.current);
|
||||||
clearTimeout(timeoutRef.current);
|
clearTimeout(timeoutRef.current);
|
||||||
// Promote device status to provisioned
|
// Promote device status to provisioned
|
||||||
|
|||||||
Reference in New Issue
Block a user