diff --git a/src/plugins/Accident.js b/src/plugins/Accident.js index 8f66c41..e9b88ee 100644 --- a/src/plugins/Accident.js +++ b/src/plugins/Accident.js @@ -9,18 +9,18 @@ import { TG_API, TG_USERID } from "../config"; function sendNotification(close) { if (window.sendingAccidentAlert) return; - window.sending = true; + window.sendingAccidentAlert = true; const bot = new Telegram(TG_API); bot.sendMessage(TG_USERID, "User detected in an accident. Location has been attached below."); navigator.geolocation.getCurrentPosition( position => { + window.sendingAccidentAlert = false; bot.sendLocation( TG_USERID, position.coords.latitude, position.coords.longitude); - window.sendingAccidentAlert = false; }, () => { - bot.sendMessage(TG_USERID, "Error retrieving location"); window.sendingAccidentAlert = false; + bot.sendMessage(TG_USERID, "Error retrieving location"); } ); setTimeout(close, 2000);