mirror of
https://codeberg.org/emersion/gamja
synced 2025-03-12 23:43:42 +01:00
components/app: throttle our focus PINGs
This commit is contained in:
parent
c6a1513a07
commit
5b8c886c91
@ -200,6 +200,7 @@ export default class App extends Component {
|
|||||||
autoOpenURL = null;
|
autoOpenURL = null;
|
||||||
messageNotifications = new Set();
|
messageNotifications = new Set();
|
||||||
baseTitle = null;
|
baseTitle = null;
|
||||||
|
lastFocusPingDate = null;
|
||||||
|
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
super(props);
|
super(props);
|
||||||
@ -1923,6 +1924,13 @@ export default class App extends Component {
|
|||||||
handleWindowFocus() {
|
handleWindowFocus() {
|
||||||
// When the user focuses gamja, send a PING to make sure we detect any
|
// When the user focuses gamja, send a PING to make sure we detect any
|
||||||
// network errors ASAP
|
// 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()) {
|
for (let client of this.clients.values()) {
|
||||||
client.send({ command: "PING", params: ["gamja"] });
|
client.send({ command: "PING", params: ["gamja"] });
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user