send notification when page is focused

Previous code was somewhat bugged
This commit is contained in:
creeper123123321 2021-04-04 08:14:50 -03:00 committed by GitHub
parent f799856df1
commit dbcce81922
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -32,13 +32,6 @@ var listening = document.getElementById("listening");
var actions = document.getElementById("actions");
var accounts = document.getElementById("accounts-list");
var listenVisible = false;
var pageBlur = false;
document.addEventListener("focus", () => {
pageBlur = false;
});
document.addEventListener("blur", () => {
pageBlur = true;
});
// Util
isMojang = it => !!it.clientToken;
@ -319,7 +312,7 @@ function handleSWMsg(event) {
callback(data.action);
}
function authNotification(msg, yes, no) {
if (!navigator.serviceWorker || (!pageBlur && !document.hidden) || Notification.permission != "granted") {
if (!navigator.serviceWorker || Notification.permission != "granted") {
if (confirm(msg)) yes(); else no();
return;
}