Browse Source

Merge pull request #44 from meriadec/master

Better auto-update. Fix raven usage in build mode.
master
Loëck Vézien 7 years ago
committed by GitHub
parent
commit
78cadaa01f
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 3
      package.json
  2. 2
      src/components/TopBar.js
  3. 62
      src/components/UpdateNotifier.js
  4. 15
      src/components/Wrapper.js
  5. 2
      src/helpers/btc.js
  6. 4
      src/main/autoUpdate.js
  7. 3
      src/main/bridge.js
  8. 4
      src/reducers/update.js
  9. 2
      src/renderer/index.js
  10. 4
      src/styles/global.js
  11. 106
      yarn.lock

3
package.json

@ -38,6 +38,7 @@
"@ledgerhq/hw-app-eth": "^1.1.2-beta.068e2a14",
"@ledgerhq/hw-transport": "^1.1.2-beta.068e2a14",
"@ledgerhq/hw-transport-node-hid": "^1.1.2-beta.068e2a14",
"@ledgerhq/common": "2.0.4",
"axios": "^0.17.1",
"bcryptjs": "^2.4.3",
"bitcoinjs-lib": "^3.3.2",
@ -50,7 +51,6 @@
"history": "^4.7.2",
"i18next": "^10.2.2",
"i18next-node-fs-backend": "^1.0.0",
"ledger-wallet-common": "github:LedgerHQ/ledger-wallet-common",
"lodash": "^4.17.4",
"object-path": "^0.11.4",
"raven": "^2.3.0",
@ -59,6 +59,7 @@
"react-dom": "^16.2.0",
"react-i18next": "^7.3.1",
"react-mortal": "^3.0.1",
"react-motion": "^0.5.2",
"react-redux": "^5.0.6",
"react-router": "^4.2.0",
"react-router-dom": "^4.2.2",

2
src/components/TopBar.js

@ -140,7 +140,7 @@ class TopBar extends PureComponent<Props, State> {
))}
</Overlay>
)}
<Box bg="white" noShrink style={{ height: 60 }} align="center" horizontal>
<Box bg="white" noShrink style={{ height: 60, zIndex: 20 }} align="center" horizontal>
<Box grow>
{sync.progress === true
? 'sync...'

62
src/components/UpdateNotifier.js

@ -1,35 +1,83 @@
// @flow
import React, { PureComponent } from 'react'
import { Motion, spring } from 'react-motion'
import { connect } from 'react-redux'
import type { MapStateToProps } from 'react-redux'
import styled from 'styled-components'
import { getUpdateStatus } from 'reducers/update'
import { getUpdateStatus, getUpdateData } from 'reducers/update'
import { sendEvent } from 'renderer/events'
import type { State } from 'reducers'
import type { UpdateStatus } from 'reducers/update'
import Box from 'components/base/Box'
import Text from 'components/base/Text'
type Props = {
updateStatus: UpdateStatus,
}
const mapStateToProps: MapStateToProps<*, *, *> = (state: State) => ({
updateStatus: getUpdateStatus(state),
updateData: getUpdateData(state),
})
const Container = styled.div`
position: fixed;
bottom: 0;
const Container = styled(Box).attrs({
p: 1,
bg: 'blue',
color: 'white',
style: p => ({
transform: `translate3d(0, ${p.offset}%, 0)`,
}),
})`
position: absolute;
top: 0;
left: 0;
right: 0;
display: flex;
justify-content: center;
z-index: 10;
`
class UpdateNotifier extends PureComponent<Props> {
renderStatus() {
const { updateStatus } = this.props
switch (updateStatus) {
case 'idle':
case 'checking':
case 'unavailable':
case 'error':
case 'available':
case 'progress':
return null
case 'downloaded':
return (
<Box horizontal flow={2}>
<Text fontWeight="bold">{'A new version is ready to be installed.'}</Text>
<Text
style={{ cursor: 'pointer' }}
onClick={() => sendEvent('msg', 'updater.quitAndInstall')}
>
{'Re-launch app now'}
</Text>
</Box>
)
default:
return null
}
}
render() {
const { updateStatus } = this.props
return <Container>{updateStatus}</Container>
const isToggled = updateStatus === 'downloaded'
return (
<Motion
style={{
offset: spring(isToggled ? 0 : -100),
}}
>
{m => <Container offset={m.offset}>{this.renderStatus()}</Container>}
</Motion>
)
}
}

15
src/components/Wrapper.js

@ -31,8 +31,6 @@ class Wrapper extends Component<{}> {
<IsUnlocked
render={() => (
<Fragment>
<UpdateNotifier />
{Object.entries(modals).map(([name, ModalComponent]: [string, any]) => (
<ModalComponent key={name} />
))}
@ -42,11 +40,14 @@ class Wrapper extends Component<{}> {
<Box shrink grow bg="cream">
<TopBar />
<GrowScroll>
<Route path="/" exact component={DashboardPage} />
<Route path="/settings" component={SettingsPage} />
<Route path="/account/:id" component={AccountPage} />
</GrowScroll>
<Box grow relative>
<UpdateNotifier />
<GrowScroll>
<Route path="/" exact component={DashboardPage} />
<Route path="/settings" component={SettingsPage} />
<Route path="/account/:id" component={AccountPage} />
</GrowScroll>
</Box>
</Box>
</Box>
</Fragment>

2
src/helpers/btc.js

@ -2,7 +2,7 @@
import axios from 'axios'
import bitcoin from 'bitcoinjs-lib'
import { formatCurrencyUnit } from 'ledger-wallet-common/lib/data/currency'
import { formatCurrencyUnit } from '@ledgerhq/common/lib/data/currency'
export function format(v: string | number, options: Object = { alwaysShowSign: true }) {
return formatCurrencyUnit(

4
src/main/autoUpdate.js

@ -14,3 +14,7 @@ export default (notify: SendFunction) => {
autoUpdater.checkForUpdatesAndNotify()
}
export function quitAndInstall() {
autoUpdater.quitAndInstall()
}

3
src/main/bridge.js

@ -5,7 +5,7 @@ import { ipcMain } from 'electron'
import objectPath from 'object-path'
import { resolve } from 'path'
import setupAutoUpdater from './autoUpdate'
import setupAutoUpdater, { quitAndInstall } from './autoUpdate'
function onForkChannel(forkType, callType) {
return (event: any, payload) => {
@ -49,6 +49,7 @@ ipcMain.on('accounts', onForkChannel('accounts', 'async'))
const handlers = {
updater: {
init: setupAutoUpdater,
quitAndInstall,
},
}

4
src/reducers/update.js

@ -39,6 +39,10 @@ export function getUpdateStatus(state: { update: UpdateState }): UpdateStatus {
return state.update.status
}
export function getUpdateData(state: { update: UpdateState }): Object {
return state.update.data || {}
}
// Default export
export default handleActions(handlers, state)

2
src/renderer/index.js

@ -18,7 +18,7 @@ import App from 'components/App'
import 'styles/global'
if (__PROD__ && __SENTRY_URL__) {
Raven.config(__SENTRY_URL__).install()
Raven.config(__SENTRY_URL__, { allowSecretKey: true }).install()
window.addEventListener('unhandledrejection', event => Raven.captureException(event.reason))
}

4
src/styles/global.js

@ -37,4 +37,8 @@ injectGlobal`
em {
font-style: italic;
}
::-webkit-scrollbar {
display: none;
}
`

106
yarn.lock

@ -78,6 +78,21 @@
lodash "^4.2.0"
to-fast-properties "^2.0.0"
"@ledgerhq/common@2.0.4":
version "2.0.4"
resolved "https://registry.yarnpkg.com/@ledgerhq/common/-/common-2.0.4.tgz#d1679bb2636bce6cdc624d9691fe38c316ae0d7e"
dependencies:
fbjs "^0.8.16"
invariant "^2.2.2"
lodash "^4.17.4"
normalizr-gre "^3.2.4"
prop-types "^15.5.10"
query-string "^5.0.0"
react "^16.0.0"
react-redux "^5.0.5"
redux "^3.7.2"
redux-thunk "^2.2.0"
"@ledgerhq/hw-app-btc@^1.1.2-beta.068e2a14":
version "1.1.2-beta.068e2a14"
resolved "https://registry.yarnpkg.com/@ledgerhq/hw-app-btc/-/hw-app-btc-1.1.2-beta.068e2a14.tgz#0e028ac16dd96808d13a846ee5adc649ba1f3a1b"
@ -565,7 +580,7 @@ array.prototype.flatten@^1.1.1:
es-abstract "^1.10.0"
function-bind "^1.1.1"
arrify@^1.0.0, arrify@^1.0.1:
arrify@^1.0.0:
version "1.0.1"
resolved "https://registry.yarnpkg.com/arrify/-/arrify-1.0.1.tgz#898508da2226f380df904728456849c1501a4b0d"
@ -738,7 +753,7 @@ babel-eslint@^8.2.1:
eslint-scope "~3.7.1"
eslint-visitor-keys "^1.0.0"
babel-generator@^6.18.0, babel-generator@^6.26.0:
babel-generator@^6.26.0:
version "6.26.0"
resolved "https://registry.yarnpkg.com/babel-generator/-/babel-generator-6.26.0.tgz#ac1ae20070b79f6e3ca1d3269613053774f20dc5"
dependencies:
@ -905,13 +920,6 @@ babel-helpers@^6.24.1:
babel-runtime "^6.22.0"
babel-template "^6.24.1"
babel-jest@^22.0.4:
version "22.1.0"
resolved "https://registry.yarnpkg.com/babel-jest/-/babel-jest-22.1.0.tgz#7fae6f655fffe77e818a8c2868c754a42463fdfd"
dependencies:
babel-plugin-istanbul "^4.1.5"
babel-preset-jest "^22.1.0"
babel-loader@^7.1.2:
version "7.1.2"
resolved "https://registry.yarnpkg.com/babel-loader/-/babel-loader-7.1.2.tgz#f6cbe122710f1aa2af4d881c6d5b54358ca24126"
@ -952,18 +960,6 @@ babel-plugin-dynamic-import-node@1.1.0:
babel-template "^6.26.0"
babel-types "^6.26.0"
babel-plugin-istanbul@^4.1.5:
version "4.1.5"
resolved "https://registry.yarnpkg.com/babel-plugin-istanbul/-/babel-plugin-istanbul-4.1.5.tgz#6760cdd977f411d3e175bb064f2bc327d99b2b6e"
dependencies:
find-up "^2.1.0"
istanbul-lib-instrument "^1.7.5"
test-exclude "^4.1.1"
babel-plugin-jest-hoist@^22.1.0:
version "22.1.0"
resolved "https://registry.yarnpkg.com/babel-plugin-jest-hoist/-/babel-plugin-jest-hoist-22.1.0.tgz#c1281dd7887d77a1711dc760468c3b8285dde9ee"
babel-plugin-minify-builtins@^0.2.0:
version "0.2.0"
resolved "https://registry.yarnpkg.com/babel-plugin-minify-builtins/-/babel-plugin-minify-builtins-0.2.0.tgz#317f824b0907210b6348671bb040ca072e2e0c82"
@ -1095,7 +1091,7 @@ babel-plugin-syntax-jsx@^6.3.13, babel-plugin-syntax-jsx@^6.8.0:
version "6.18.0"
resolved "https://registry.yarnpkg.com/babel-plugin-syntax-jsx/-/babel-plugin-syntax-jsx-6.18.0.tgz#0af32a9a6e13ca7a3fd5069e62d7b0f58d0d8946"
babel-plugin-syntax-object-rest-spread@^6.13.0, babel-plugin-syntax-object-rest-spread@^6.8.0:
babel-plugin-syntax-object-rest-spread@^6.8.0:
version "6.13.0"
resolved "https://registry.yarnpkg.com/babel-plugin-syntax-object-rest-spread/-/babel-plugin-syntax-object-rest-spread-6.13.0.tgz#fd6536f2bce13836ffa3a5458c4903a597bb3bf5"
@ -1507,13 +1503,6 @@ babel-preset-flow@^6.23.0:
dependencies:
babel-plugin-transform-flow-strip-types "^6.22.0"
babel-preset-jest@^22.1.0:
version "22.1.0"
resolved "https://registry.yarnpkg.com/babel-preset-jest/-/babel-preset-jest-22.1.0.tgz#ff4e704102f9642765e2254226050561d8942ec9"
dependencies:
babel-plugin-jest-hoist "^22.1.0"
babel-plugin-syntax-object-rest-spread "^6.13.0"
babel-preset-minify@^0.2.0:
version "0.2.0"
resolved "https://registry.yarnpkg.com/babel-preset-minify/-/babel-preset-minify-0.2.0.tgz#006566552d9b83834472273f306c0131062a0acc"
@ -1625,7 +1614,7 @@ babel-runtime@6.x.x, babel-runtime@^6.11.6, babel-runtime@^6.18.0, babel-runtime
core-js "^2.4.0"
regenerator-runtime "^0.11.0"
babel-template@^6.16.0, babel-template@^6.24.1, babel-template@^6.26.0:
babel-template@^6.24.1, babel-template@^6.26.0:
version "6.26.0"
resolved "https://registry.yarnpkg.com/babel-template/-/babel-template-6.26.0.tgz#de03e2d16396b069f46dd9fff8521fb1a0e35e02"
dependencies:
@ -1635,7 +1624,7 @@ babel-template@^6.16.0, babel-template@^6.24.1, babel-template@^6.26.0:
babylon "^6.18.0"
lodash "^4.17.4"
babel-traverse@^6.18.0, babel-traverse@^6.24.1, babel-traverse@^6.26.0:
babel-traverse@^6.24.1, babel-traverse@^6.26.0:
version "6.26.0"
resolved "https://registry.yarnpkg.com/babel-traverse/-/babel-traverse-6.26.0.tgz#46a9cbd7edcc62c8e5c064e2d2d8d0f4035766ee"
dependencies:
@ -1649,7 +1638,7 @@ babel-traverse@^6.18.0, babel-traverse@^6.24.1, babel-traverse@^6.26.0:
invariant "^2.2.2"
lodash "^4.17.4"
babel-types@^6.18.0, babel-types@^6.19.0, babel-types@^6.24.1, babel-types@^6.26.0:
babel-types@^6.19.0, babel-types@^6.24.1, babel-types@^6.26.0:
version "6.26.0"
resolved "https://registry.yarnpkg.com/babel-types/-/babel-types-6.26.0.tgz#a3b073f94ab49eb6fa55cd65227a334380632497"
dependencies:
@ -5235,22 +5224,6 @@ isstream@~0.1.2:
version "0.1.2"
resolved "https://registry.yarnpkg.com/isstream/-/isstream-0.1.2.tgz#47e63f7af55afa6f92e1500e690eb8b8529c099a"
istanbul-lib-coverage@^1.1.1:
version "1.1.1"
resolved "https://registry.yarnpkg.com/istanbul-lib-coverage/-/istanbul-lib-coverage-1.1.1.tgz#73bfb998885299415c93d38a3e9adf784a77a9da"
istanbul-lib-instrument@^1.7.5:
version "1.9.1"
resolved "https://registry.yarnpkg.com/istanbul-lib-instrument/-/istanbul-lib-instrument-1.9.1.tgz#250b30b3531e5d3251299fdd64b0b2c9db6b558e"
dependencies:
babel-generator "^6.18.0"
babel-template "^6.16.0"
babel-traverse "^6.18.0"
babel-types "^6.18.0"
babylon "^6.18.0"
istanbul-lib-coverage "^1.1.1"
semver "^5.3.0"
isurl@^1.0.0-alpha5:
version "1.0.0"
resolved "https://registry.yarnpkg.com/isurl/-/isurl-1.0.0.tgz#b27f4f49f3cdaa3ea44a0a5b7f3462e6edc39d67"
@ -5445,23 +5418,6 @@ lcid@^1.0.0:
dependencies:
invert-kv "^1.0.0"
"ledger-wallet-common@github:LedgerHQ/ledger-wallet-common":
version "0.0.0"
resolved "https://codeload.github.com/LedgerHQ/ledger-wallet-common/tar.gz/efc7c7970ef4c9bf327d8f5272d700c46c8f4764"
dependencies:
babel-jest "^22.0.4"
fbjs "^0.8.16"
invariant "^2.2.2"
lodash "^4.17.4"
normalizr-gre "^3.2.4"
prop-types "^15.5.10"
query-string "^5.0.0"
react "^16.0.0"
react-redux "^5.0.5"
react-test-renderer "^16.2.0"
redux "^3.7.2"
redux-thunk "^2.2.0"
leven@^2.1.0:
version "2.1.0"
resolved "https://registry.yarnpkg.com/leven/-/leven-2.1.0.tgz#c2e7a9f772094dee9d34202ae8acce4687875580"
@ -7357,7 +7313,7 @@ react-mortal@^3.0.1:
react-motion "^0.5.0"
react-portal "^4.0.0"
react-motion@^0.5.0:
react-motion@^0.5.0, react-motion@^0.5.2:
version "0.5.2"
resolved "https://registry.yarnpkg.com/react-motion/-/react-motion-0.5.2.tgz#0dd3a69e411316567927917c6626551ba0607316"
dependencies:
@ -7439,14 +7395,6 @@ react-style-proptype@^3.0.0:
dependencies:
prop-types "^15.5.4"
react-test-renderer@^16.2.0:
version "16.2.0"
resolved "https://registry.yarnpkg.com/react-test-renderer/-/react-test-renderer-16.2.0.tgz#bddf259a6b8fcd8555f012afc8eacc238872a211"
dependencies:
fbjs "^0.8.16"
object-assign "^4.1.1"
prop-types "^15.6.0"
react-textarea-autosize@^5.2.1:
version "5.2.1"
resolved "https://registry.yarnpkg.com/react-textarea-autosize/-/react-textarea-autosize-5.2.1.tgz#2b78f9067180f41b08ac59f78f1581abadd61e54"
@ -8701,16 +8649,6 @@ term-size@^1.2.0:
dependencies:
execa "^0.7.0"
test-exclude@^4.1.1:
version "4.1.1"
resolved "https://registry.yarnpkg.com/test-exclude/-/test-exclude-4.1.1.tgz#4d84964b0966b0087ecc334a2ce002d3d9341e26"
dependencies:
arrify "^1.0.1"
micromatch "^2.3.11"
object-assign "^4.1.0"
read-pkg-up "^1.0.1"
require-main-filename "^1.0.1"
text-table@~0.2.0:
version "0.2.0"
resolved "https://registry.yarnpkg.com/text-table/-/text-table-0.2.0.tgz#7f5ee823ae805207c00af2df4a84ec3fcfa570b4"

Loading…
Cancel
Save