Reload frontend if backend changes#5489
Merged
bramkragten merged 3 commits intodevfrom Apr 10, 2020
Merged
Conversation
bramkragten
reviewed
Apr 8, 2020
| // Force a reload if we reconnect to a new version so we load | ||
| // latest frontend. | ||
| conn.addEventListener("ready", (conn2) => { | ||
| if (conn2.haVersion !== curVersion) { |
Member
There was a problem hiding this comment.
Shouldn't this be done in hassReconnected in the connection-mixin?
Member
Author
There was a problem hiding this comment.
oh reconnected is a good one.
I didn't want to put it in the connection mixin because it's specific to the frontend, and I wouldn't want to add it into Cast.
Member
Author
|
Now made sure we also handle the case where we are loaded from a service worker. |
bramkragten
reviewed
Apr 8, 2020
| @property() private _route?: Route; | ||
| @property() private _error = false; | ||
| @property() private _panelUrl?: string; | ||
| private _haVersion?: string; |
bramkragten
reviewed
Apr 8, 2020
| // If backend has been upgraded, make sure we update frontend | ||
| if (this.hass!.connection.haVersion !== this._haVersion) { | ||
| if (supportsServiceWorker()) { | ||
| navigator.serviceWorker.getRegistration().then((registration) => { |
Member
There was a problem hiding this comment.
Suggested change
| navigator.serviceWorker.getRegistration().then((registration) => { | |
| navigator.serviceWorker.ready.then((registration) => { |
Member
Author
There was a problem hiding this comment.
We don't need to know if the worker is active. We just want to know if we have one, and if we have one, we want to tell the browser that it should update the worker.
bramkragten
approved these changes
Apr 10, 2020
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Breaking change
Proposed change
We use code splitting to break up the frontend in pieces. If we update Home Assistant and the frontend is loaded, the frontend will try to load pieces that are no longer available, resulting in blank screens and errors.
With this fix, if the connection reconnects and discovers a change in Home Assistant version, reload the frontend.
Type of change
Example configuration
Additional information
Checklist
If user exposed functionality or configuration variables are added/changed: