diff --git a/app/background/setting/client.js b/app/background/setting/client.js index fd7bb9b1d..368c39deb 100644 --- a/app/background/setting/client.js +++ b/app/background/setting/client.js @@ -7,4 +7,5 @@ export const clientStub = ipcRendererInjector => makeClient(ipcRendererInjector, 'setLocale', 'getCustomLocale', 'setCustomLocale', + 'getLatestRelease', ]); diff --git a/app/background/setting/service.js b/app/background/setting/service.js index ede0bb26a..d1d10bdac 100644 --- a/app/background/setting/service.js +++ b/app/background/setting/service.js @@ -37,6 +37,21 @@ export async function setCustomLocale(json) { return await put(CUSTOM_LOCALE, JSON.stringify(json)); } +export async function getLatestRelease() { + try { + const releases = await ( + await fetch( + 'https://api.github.com/repos/kyokan/bob-wallet/releases' + ) + ).json(); + const latest = releases.filter(r => !r.draft && !r.prerelease)[0]; + return latest; + } catch (error) { + console.error(error); + return null; + } +} + const sName = 'Setting'; const methods = { getExplorer, @@ -45,6 +60,7 @@ const methods = { setLocale, getCustomLocale, setCustomLocale, + getLatestRelease, }; export async function start(server) { diff --git a/app/components/Sidebar/index.js b/app/components/Sidebar/index.js index 66de16eb1..1dfbe207f 100644 --- a/app/components/Sidebar/index.js +++ b/app/components/Sidebar/index.js @@ -1,3 +1,4 @@ +import { shell } from 'electron'; import React, { Component } from 'react'; import { withRouter, NavLink } from 'react-router-dom'; import PropTypes from 'prop-types'; @@ -22,6 +23,7 @@ const nodeClient = clientStub(() => require('electron').ipcRenderer); walletSync: state.wallet.walletSync, walletHeight: state.wallet.walletHeight, address: state.wallet.address, + updateAvailable: state.app.updateAvailable, }), dispatch => ({ @@ -44,6 +46,7 @@ class Sidebar extends Component { walletHeight: PropTypes.number.isRequired, network: PropTypes.string.isRequired, address: PropTypes.string.isRequired, + updateAvailable: PropTypes.object, }; static contextType = I18nContext; @@ -199,13 +202,27 @@ class Sidebar extends Component { newBlockStatus, chainHeight, tip, + updateAvailable, } = this.props; return (