Reinitialize JS views on reconnection (#1270)

This commit is contained in:
Jonatan Kłosko 2022-07-11 20:19:32 +01:00 committed by GitHub
parent a4e645defa
commit e82279d9af
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 1 deletions

View file

@ -146,6 +146,11 @@ const JSView = {
this.props = this.getProps(this);
},
disconnected() {
// Reinitialize on reconnection
this.el.removeAttribute("id");
},
destroyed() {
window.removeEventListener("message", this._handleWindowMessage);

View file

@ -233,6 +233,10 @@ const Session = {
disconnected() {
// Reinitialize on reconnection
this.el.removeAttribute("id");
// If we reconnect, a new hook is mounted and it becomes responsible
// for leaving the channel when destroyed
this.keepChannel = true;
},
destroyed() {
@ -246,7 +250,9 @@ const Session = {
setFavicon("favicon");
leaveChannel();
if (!this.keepChannel) {
leaveChannel();
}
},
getProps() {