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

Commit

Permalink
[C-838] Fix desktop update banner flow (#1719)
Browse files Browse the repository at this point in the history
* [C-838] Avoid sending auto update when only patch

* Fix

* Fix var
  • Loading branch information
raymondjacobson committed Sep 14, 2022
1 parent 81e9a4d commit 24d9d3b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 21 deletions.
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
30 changes: 9 additions & 21 deletions packages/web/src/pages/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -207,10 +207,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 @@ -253,7 +256,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 All @@ -276,7 +278,7 @@ class App extends Component {
if (semver.lt(currentVersion, minAppVersion)) {
this.setState({ showRequiresWebUpdate: true })
} else {
this.setState({ showWebUpdate: true })
this.setState({ showWebUpdateBanner: true })
}
})

Expand Down Expand Up @@ -424,9 +426,6 @@ class App extends Component {
}

acceptUpdateApp = () => {
if (this.state.showUpdateAppBanner) {
this.dismissUpdateAppBanner()
}
this.setState({ isUpdating: true })
this.ipc.send('update')
}
Expand All @@ -441,10 +440,6 @@ class App extends Component {
this.ipc.send('web-update')
}

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

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

const {
showCTABanner,
showUpdateAppBanner,
showWebUpdate,
showWebUpdateBanner,
showWeb3ErrorBanner,
isUpdating,
showRequiresUpdate,
Expand Down Expand Up @@ -504,7 +498,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 @@ -527,20 +521,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

0 comments on commit 24d9d3b

Please sign in to comment.