mirror of
https://github.com/livebook-dev/livebook.git
synced 2025-09-14 08:54:35 +08:00
Reinitialize JS views on reconnection (#1270)
This commit is contained in:
parent
a4e645defa
commit
e82279d9af
2 changed files with 12 additions and 1 deletions
|
@ -146,6 +146,11 @@ const JSView = {
|
||||||
this.props = this.getProps(this);
|
this.props = this.getProps(this);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
disconnected() {
|
||||||
|
// Reinitialize on reconnection
|
||||||
|
this.el.removeAttribute("id");
|
||||||
|
},
|
||||||
|
|
||||||
destroyed() {
|
destroyed() {
|
||||||
window.removeEventListener("message", this._handleWindowMessage);
|
window.removeEventListener("message", this._handleWindowMessage);
|
||||||
|
|
||||||
|
|
|
@ -233,6 +233,10 @@ const Session = {
|
||||||
disconnected() {
|
disconnected() {
|
||||||
// Reinitialize on reconnection
|
// Reinitialize on reconnection
|
||||||
this.el.removeAttribute("id");
|
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() {
|
destroyed() {
|
||||||
|
@ -246,7 +250,9 @@ const Session = {
|
||||||
|
|
||||||
setFavicon("favicon");
|
setFavicon("favicon");
|
||||||
|
|
||||||
leaveChannel();
|
if (!this.keepChannel) {
|
||||||
|
leaveChannel();
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
getProps() {
|
getProps() {
|
||||||
|
|
Loading…
Add table
Reference in a new issue