aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Ser <contact@emersion.fr>2023-11-26 16:43:42 +0100
committerSimon Ser <contact@emersion.fr>2023-11-26 16:43:42 +0100
commit5b8c886c917174f979d57ab3216d328e8d31f237 (patch)
treef249027d2b3a7325476ac8deb4b77f63aa3057a0
parentc6a1513a070560f9d8af7ec64cde7a145f5191bd (diff)
downloadgamja-5b8c886c917174f979d57ab3216d328e8d31f237.tar.gz
gamja-5b8c886c917174f979d57ab3216d328e8d31f237.zip
components/app: throttle our focus PINGs
-rw-r--r--components/app.js8
1 files changed, 8 insertions, 0 deletions
diff --git a/components/app.js b/components/app.js
index 4788788..a27c915 100644
--- a/components/app.js
+++ b/components/app.js
@@ -200,6 +200,7 @@ export default class App extends Component {
autoOpenURL = null;
messageNotifications = new Set();
baseTitle = null;
+ lastFocusPingDate = null;
constructor(props) {
super(props);
@@ -1923,6 +1924,13 @@ export default class App extends Component {
handleWindowFocus() {
// When the user focuses gamja, send a PING to make sure we detect any
// network errors ASAP
+
+ let now = new Date();
+ if (this.lastFocusPingDate && now.getTime() - this.lastFocusPingDate.getTime() < 15 * 1000) {
+ return;
+ }
+ this.lastFocusPingDate = now;
+
for (let client of this.clients.values()) {
client.send({ command: "PING", params: ["gamja"] });
}