Skip to content

Commit

Permalink
Fix window null on connection error. Closes #2716
Browse files Browse the repository at this point in the history
  • Loading branch information
chrismccord committed Sep 19, 2023
1 parent 14a0355 commit 633f356
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 13 deletions.
6 changes: 4 additions & 2 deletions assets/js/phoenix_live_view/view.js
Original file line number Diff line number Diff line change
Expand Up @@ -656,10 +656,12 @@ export default class View {
onJoinError(resp){
if(resp.reason === "reload"){
this.log("error", () => [`failed mount with ${resp.status}. Falling back to page request`, resp])
return this.onRedirect({to: this.href})
if(this.isMain()){ this.onRedirect({to: this.href}) }
return
} else if(resp.reason === "unauthorized" || resp.reason === "stale"){
this.log("error", () => ["unauthorized live_redirect. Falling back to page request", resp])
return this.onRedirect({to: this.href})
if(this.isMain()){ this.onRedirect({to: this.href}) }
return
}
if(resp.redirect || resp.live_redirect){
this.joinPending = false
Expand Down
10 changes: 8 additions & 2 deletions priv/static/phoenix_live_view.cjs.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions priv/static/phoenix_live_view.cjs.js.map

Large diffs are not rendered by default.

10 changes: 8 additions & 2 deletions priv/static/phoenix_live_view.esm.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions priv/static/phoenix_live_view.esm.js.map

Large diffs are not rendered by default.

10 changes: 8 additions & 2 deletions priv/static/phoenix_live_view.js
Original file line number Diff line number Diff line change
Expand Up @@ -3166,10 +3166,16 @@ within:
onJoinError(resp) {
if (resp.reason === "reload") {
this.log("error", () => [`failed mount with ${resp.status}. Falling back to page request`, resp]);
return this.onRedirect({ to: this.href });
if (this.isMain()) {
this.onRedirect({ to: this.href });
}
return;
} else if (resp.reason === "unauthorized" || resp.reason === "stale") {
this.log("error", () => ["unauthorized live_redirect. Falling back to page request", resp]);
return this.onRedirect({ to: this.href });
if (this.isMain()) {
this.onRedirect({ to: this.href });
}
return;
}
if (resp.redirect || resp.live_redirect) {
this.joinPending = false;
Expand Down
2 changes: 1 addition & 1 deletion priv/static/phoenix_live_view.min.js

Large diffs are not rendered by default.

0 comments on commit 633f356

Please sign in to comment.