mirror of
https://github.com/ViaVersion/VIAaaS.git
synced 2024-11-29 13:15:15 +01:00
send notification when page is focused
Previous code was somewhat bugged
This commit is contained in:
parent
f799856df1
commit
dbcce81922
@ -32,13 +32,6 @@ var listening = document.getElementById("listening");
|
|||||||
var actions = document.getElementById("actions");
|
var actions = document.getElementById("actions");
|
||||||
var accounts = document.getElementById("accounts-list");
|
var accounts = document.getElementById("accounts-list");
|
||||||
var listenVisible = false;
|
var listenVisible = false;
|
||||||
var pageBlur = false;
|
|
||||||
document.addEventListener("focus", () => {
|
|
||||||
pageBlur = false;
|
|
||||||
});
|
|
||||||
document.addEventListener("blur", () => {
|
|
||||||
pageBlur = true;
|
|
||||||
});
|
|
||||||
|
|
||||||
// Util
|
// Util
|
||||||
isMojang = it => !!it.clientToken;
|
isMojang = it => !!it.clientToken;
|
||||||
@ -319,7 +312,7 @@ function handleSWMsg(event) {
|
|||||||
callback(data.action);
|
callback(data.action);
|
||||||
}
|
}
|
||||||
function authNotification(msg, yes, no) {
|
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();
|
if (confirm(msg)) yes(); else no();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user