From 22e159690e534b4355878aaa24e7d46a52f6abc7 Mon Sep 17 00:00:00 2001 From: altaf-creator Date: Mon, 1 Dec 2025 18:17:03 +0700 Subject: onesignal actually works now --- frontend/start.js | 20 ++++++++++++-------- frontend/start/index.html | 2 ++ 2 files changed, 14 insertions(+), 8 deletions(-) (limited to 'frontend') diff --git a/frontend/start.js b/frontend/start.js index 5c9fc5d..374c68d 100644 --- a/frontend/start.js +++ b/frontend/start.js @@ -1,4 +1,8 @@ -document.getElementById("startbtn").addEventListener("click", () => { +const notif = document.getElementById("notif-panel"); +const notbtn = document.getElementById("notbtn"); +const startbtn = document.getElementById("startbtn"); + +startbtn.addEventListener("click", () => { start(); }); @@ -8,8 +12,13 @@ console.log(urlParams); startUpdateMachines(); -const notbtn = document.getElementById("notbtn"); -const startbtn = document.getElementById("startbtn"); +OneSignalDeferred.push(async function(OneSignal) { + if (OneSignal.Notifications.permission) { + notif.remove(); + startbtn.disabled = false; + } +}); + notbtn.addEventListener("click", () => requestPermission()) async function requestPermission() { console.log("Requesting permission..."); @@ -19,8 +28,3 @@ async function requestPermission() { startbtn.disabled = false; } } -const notif = document.getElementById("notif-panel"); -if (OneSignal.Notifications.permission) { - notif.remove(); - startbtn.disabled = false; -} diff --git a/frontend/start/index.html b/frontend/start/index.html index 0f8a0cf..ec3f976 100644 --- a/frontend/start/index.html +++ b/frontend/start/index.html @@ -16,6 +16,8 @@ }, }); }); + + -- cgit v1.2.3