Fix repeating notifications in Accident.js

This commit is contained in:
Ceda EI 2021-01-06 13:55:56 +05:30
parent d4a19060e8
commit a1dc088a23
1 changed files with 3 additions and 3 deletions

View File

@ -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);