Skip to content
This repository has been archived by the owner on Oct 4, 2023. It is now read-only.

[C-838] Fix desktop update banner flow #1719

Merged
merged 3 commits into from
Sep 14, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions packages/web/src/electron.js
Original file line number Diff line number Diff line change
Expand Up @@ -468,13 +468,15 @@ ipcMain.on('quit', (event, arg) => {
app.exit(0)
})

// We have finished downloading the electron update
autoUpdater.on('update-downloaded', (info) => {
console.log('update-downloaded', info)
canUpdate = true
info.currentVersion = autoUpdater.currentVersion.version
if (mainWindow) mainWindow.webContents.send('updateDownloaded', info)
})

// We have discovered that there is an available electron update
autoUpdater.on('update-available', (info) => {
console.log('update-available', info)
info.currentVersion = autoUpdater.currentVersion.version
Expand Down
28 changes: 8 additions & 20 deletions packages/web/src/pages/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -209,10 +209,13 @@ class App extends Component {
showCTABanner: false,
showWeb3ErrorBanner: null,

showUpdateAppBanner: false,
// A patch version update of the web app is available
showWebUpdateBanner: false,
showRequiresUpdate: false,
// A version update of the web app is required
showRequiresWebUpdate: false,
// A minor version update of the entire electron app is required
showRequiresUpdate: false,

isUpdating: false,

initialPage: true,
Expand Down Expand Up @@ -255,7 +258,6 @@ class App extends Component {
// We downloaded an update, the user can safely restart
this.ipc.on('updateDownloaded', (event, arg) => {
console.info('updateDownload', event, arg)
this.setState({ showUpdateAppBanner: true })
})

this.ipc.on('updateDownloadProgress', (event, arg) => {
Expand Down Expand Up @@ -437,9 +439,6 @@ class App extends Component {
}

acceptUpdateApp = () => {
if (this.state.showUpdateAppBanner) {
this.dismissUpdateAppBanner()
}
Comment on lines -440 to -442
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this no longer necessary because the app is going to restart on update and not show the banner after?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Basically there are two flows for upgrading desktop:

  • An update to entire electron app (you need a new chromium basically)
  • An update to just the static JS for the SPA
    KJ added the latter recently, which lets us basically not worry about showing a banner for the former and letting auto update on quit take care of that behind the scenes. There's still banner that shows that will get dismissed in the below method (acceptWebUpdate) but that's for the latter SPA refresh

this.setState({ isUpdating: true })
this.ipc.send('update')
}
Expand All @@ -454,10 +453,6 @@ class App extends Component {
this.ipc.send('web-update')
}

dismissUpdateAppBanner = () => {
this.setState({ showUpdateAppBanner: false })
}

dismissUpdateWebAppBanner = () => {
this.setState({ showWebUpdateBanner: false })
}
Expand Down Expand Up @@ -487,8 +482,7 @@ class App extends Component {

const {
showCTABanner,
showUpdateAppBanner,
showWebUpdate,
showWebUpdateBanner,
showWeb3ErrorBanner,
isUpdating,
showRequiresUpdate,
Expand Down Expand Up @@ -517,7 +511,7 @@ class App extends Component {
)

const showBanner =
showCTABanner || showUpdateAppBanner || showWeb3ErrorBanner
showCTABanner || showWeb3ErrorBanner || showWebUpdateBanner
if (this.headerGutterRef.current) {
if (showBanner) {
this.headerGutterRef.current.classList.add(styles.bannerMargin)
Expand All @@ -540,20 +534,14 @@ class App extends Component {
onAccept={this.showDownloadAppModal}
/>
) : null}
{showUpdateAppBanner ? (
<UpdateAppBanner
onClose={this.dismissUpdateAppBanner}
onAccept={this.acceptUpdateApp}
/>
) : null}
{showWeb3ErrorBanner ? (
<Web3ErrorBanner
alert
isElectron={client === Client.ELECTRON}
onClose={this.dismissWeb3ErrorBanner}
/>
) : null}
{showWebUpdate ? (
{showWebUpdateBanner ? (
<UpdateAppBanner
onAccept={this.acceptWebUpdate}
onClose={this.dismissUpdateWebAppBanner}
Expand Down