aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/client/Main.hx14
1 files changed, 12 insertions, 2 deletions
diff --git a/src/client/Main.hx b/src/client/Main.hx
index 729658c..9a4c809 100644
--- a/src/client/Main.hx
+++ b/src/client/Main.hx
@@ -65,6 +65,8 @@ class Main {
var onBlinkTab:Null<Timer>;
var gotFirstPageInteraction = false;
var msgBuf = getEl("#messagebuffer");
+ var isPageUnloading = false;
+ var isPageVisible = true;
static function main():Void {
new Main();
@@ -114,6 +116,12 @@ class Main {
JsApi.init(this, player);
document.addEventListener("click", onFirstInteraction);
+ window.addEventListener("beforeunload", () -> isPageUnloading = true);
+ window.addEventListener("blur", () -> isPageVisible = false);
+ window.addEventListener("focus", () -> isPageVisible = true);
+ document.addEventListener("visibilitychange", () -> {
+ isPageVisible = document.visibilityState == VISIBLE;
+ });
}
function onFirstInteraction():Void {
@@ -1463,11 +1471,13 @@ class Main {
}
public function hasLeaderOnPauseRequest():Bool {
- return config.requestLeaderOnPause;
+ final hasAccess = isPageVisible && !isPageUnloading;
+ return config.requestLeaderOnPause && hasAccess;
}
public function hasUnpauseWithoutLeader():Bool {
- return config.unpauseWithoutLeader;
+ final hasAccess = isPageVisible && !isPageUnloading;
+ return config.unpauseWithoutLeader && hasAccess;
}
public function getTemplateUrl():String {
send patches to the email below
yukais@pinapelz.com
include the subject [PATCH repo_name]
pinapelz.com
homepage