mirror of
https://codeberg.org/emersion/gamja.git
synced 2024-11-14 19:05:01 -05:00
Send PING on window focus
References: https://todo.sr.ht/~emersion/gamja/148
This commit is contained in:
parent
3a95fd5ba4
commit
3b383308d4
1 changed files with 11 additions and 0 deletions
|
@ -228,6 +228,7 @@ export default class App extends Component {
|
||||||
this.handleSettingsChange = this.handleSettingsChange.bind(this);
|
this.handleSettingsChange = this.handleSettingsChange.bind(this);
|
||||||
this.handleSettingsDisconnect = this.handleSettingsDisconnect.bind(this);
|
this.handleSettingsDisconnect = this.handleSettingsDisconnect.bind(this);
|
||||||
this.handleSwitchSubmit = this.handleSwitchSubmit.bind(this);
|
this.handleSwitchSubmit = this.handleSwitchSubmit.bind(this);
|
||||||
|
this.handleWindowFocus = this.handleWindowFocus.bind(this);
|
||||||
|
|
||||||
this.state.settings = {
|
this.state.settings = {
|
||||||
...this.state.settings,
|
...this.state.settings,
|
||||||
|
@ -1912,13 +1913,23 @@ export default class App extends Component {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
handleWindowFocus() {
|
||||||
|
// When the user focuses gamja, send a PING to make sure we detect any
|
||||||
|
// network errors ASAP
|
||||||
|
for (let client of this.clients.values()) {
|
||||||
|
client.send({ command: "PING", params: ["gamja"] });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
this.baseTitle = document.title;
|
this.baseTitle = document.title;
|
||||||
setupKeybindings(this);
|
setupKeybindings(this);
|
||||||
|
window.addEventListener("focus", this.handleWindowFocus);
|
||||||
}
|
}
|
||||||
|
|
||||||
componentWillUnmount() {
|
componentWillUnmount() {
|
||||||
document.title = this.baseTitle;
|
document.title = this.baseTitle;
|
||||||
|
window.removeEventListener("focus", this.handleWindowFocus);
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
|
|
Loading…
Reference in a new issue