diff --git a/src/app/css/components/_updateMessage.scss b/src/app/css/components/_updateMessage.scss index b6d8844..a35d58d 100644 --- a/src/app/css/components/_updateMessage.scss +++ b/src/app/css/components/_updateMessage.scss @@ -6,9 +6,15 @@ justify-content: center; align-items: center; top: 0; - span { + > span { border-radius: 5px; padding: 10px; - background-origin: #e6e6e6; + background-color: #e6e6e6; + display: flex; + align-items: center; + flex-flow: column; + a { + color: blue; + } } } \ No newline at end of file diff --git a/src/app/html/index.html b/src/app/html/index.html index a838ba2..6f3cbc2 100644 --- a/src/app/html/index.html +++ b/src/app/html/index.html @@ -10,6 +10,7 @@
diff --git a/src/app/js/components/UpdateMessage.js b/src/app/js/components/UpdateMessage.js index 0cd47b6..c66e7f9 100644 --- a/src/app/js/components/UpdateMessage.js +++ b/src/app/js/components/UpdateMessage.js @@ -6,13 +6,14 @@ class UpdateMessage extends Component { this.state = { visible: false, - error: false + error: false, + latest: '' } } - componentDidMount() { - ipcRenderer.on('showUpdateNotification', (event, url) => { - this.setState({visible: true, error: false}) + componentDidMount () { + ipcRenderer.on('showUpdateNotification', (event, latest) => { + this.setState({visible: true, error: false, latest}) }) ipcRenderer.on('showUpdateErrorNotification', (event, error) => { @@ -20,14 +21,25 @@ class UpdateMessage extends Component { }) } + openUrl () { + shell.openExternal("https://github.com/AppSaloon/socket.io-tester/releases") + } + render () { const state = this.state const error = state.error const errorMessage = Object.prototype.toString.apply(error).slice(8, -1) === 'Object' ? `${error.message} - ${error.documentation_url}` || `Error: ${JSON.stringify(error)}` : `Error: ${JSON.stringify(error)}` return ( -
+
this.setState({visible: false}) }> { !state.error ? - update please + e.stopPropagation() }> + {`This version of the app is outdated, the latest version is ${state.latest}.`} + + Get it + here + . + + : {state.error.message || ''} } diff --git a/src/electron/checkVersion.js b/src/electron/checkVersion.js index 1f77aad..fabd757 100644 --- a/src/electron/checkVersion.js +++ b/src/electron/checkVersion.js @@ -21,8 +21,8 @@ function getRelease () { res.on("end", function () { const body = Buffer.concat(chunks) - if ( res.statusCode !== 200 ) return reject(body.toString()) - return resolve(body.toString()) + if ( res.statusCode !== 200 ) return reject(JSON.parse(body.toString())) + return resolve(JSON.parse(body.toString())) }) }) @@ -37,16 +37,11 @@ async function checkVersion (appWindow) { win = appWindow try { const release = await getRelease() - if ( Object.prototype.toString.apply(release).slice(8, -1) === 'Object' && release.name === version ) - sendMessageToWindow({channel: 'showUpdateNotification'}) + if ( Object.prototype.toString.apply(release).slice(8, -1) === 'Object' && release.name !== `v${version}` ) + sendMessageToWindow({channel: 'showUpdateNotification', message: release.name}) } catch (error) { - let parsedError = error - try { - parsedError = JSON.parse(error) - } - catch (error) {} - sendMessageToWindow({channel: 'showUpdateErrorNotification', message: parsedError}) + sendMessageToWindow({channel: 'showUpdateErrorNotification', message: error}) } }