From ef915e84b77f184ac87aa5bece94a73212dba64d Mon Sep 17 00:00:00 2001 From: Muhammad Izza Alfiansyah Date: Mon, 8 Jul 2024 23:47:18 +0700 Subject: [PATCH] fixed pengaturan check --- website/src/App.tsx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/website/src/App.tsx b/website/src/App.tsx index 3e3829c..52fbe75 100644 --- a/website/src/App.tsx +++ b/website/src/App.tsx @@ -106,9 +106,7 @@ export default function (props: JSX.HTMLAttributes) { }; const checkStatusDevice = async () => { - await getLastHistori(); - - if (!lastHistori()) { + if (pengaturan()?.running) { const lastData1: any = await new Promise(async (res) => { const { data } = await supabase .from("realtime_data") @@ -141,6 +139,8 @@ export default function (props: JSX.HTMLAttributes) { // .order("created_time", { ascending: false }) // .limit(1); + console.log(lastData1![0], lastData2![0]); + if (lastData1![0] == lastData2![0]) { alert("Device offline!"); } else if (lastData1![0].created_time == lastData2![0].created_time) { @@ -161,6 +161,7 @@ export default function (props: JSX.HTMLAttributes) { } } else { setCanNavigate(true); + await getLastHistori(); await checkStatusDevice(); await checkPengaturan(); } @@ -169,7 +170,6 @@ export default function (props: JSX.HTMLAttributes) { const turnOffBuzzer = async () => { await supabase.from("pengaturan").update({ buzzer_on: false }).eq("id", 1); - await checkPengaturan(); }; const toggleSidebar = () => {