Fix repeating notifications in Accident.js
This commit is contained in:
parent
d4a19060e8
commit
a1dc088a23
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue