Browse Source

install/uninstall is throttle/filtered/mapped on live-common side

gre-patch-1
Gaëtan Renaudeau 6 years ago
parent
commit
c950d68ea6
No known key found for this signature in database GPG Key ID: 7B66B85F042E5451
  1. 2
      package.json
  2. 4
      src/commands/installApp.js
  3. 2
      src/commands/uninstallApp.js
  4. 14
      src/components/ManagerPage/AppsList.js
  5. 8
      yarn.lock

2
package.json

@ -41,7 +41,7 @@
"@ledgerhq/hw-transport": "^4.32.0",
"@ledgerhq/hw-transport-node-hid": "^4.32.0",
"@ledgerhq/ledger-core": "2.0.0-rc.14",
"@ledgerhq/live-common": "4.8.0-beta.13",
"@ledgerhq/live-common": "4.8.0-beta.14",
"animated": "^0.2.2",
"async": "^2.6.1",
"axios": "^0.18.0",

4
src/commands/installApp.js

@ -1,7 +1,5 @@
// @flow
import { createCommand, Command } from 'helpers/ipc'
import installApp from '@ledgerhq/live-common/lib/hw/installApp'
import { withDevice } from '@ledgerhq/live-common/lib/hw/deviceAccess'
import type { ApplicationVersion } from '@ledgerhq/live-common/lib/types/manager'
@ -12,7 +10,7 @@ type Input = {
app: ApplicationVersion,
}
type Result = *
type Result = { progress: number }
const cmd: Command<Input, Result> = createCommand('installApp', ({ devicePath, targetId, app }) =>
withDevice(devicePath)(transport => installApp(transport, targetId, app)),

2
src/commands/uninstallApp.js

@ -1,9 +1,7 @@
// @flow
import { createCommand, Command } from 'helpers/ipc'
import { withDevice } from '@ledgerhq/live-common/lib/hw/deviceAccess'
import uninstallApp from '@ledgerhq/live-common/lib/hw/uninstallApp'
import type { ApplicationVersion } from '@ledgerhq/live-common/lib/types/manager'
type Input = {

14
src/components/ManagerPage/AppsList.js

@ -6,7 +6,6 @@ import styled from 'styled-components'
import { translate } from 'react-i18next'
import { connect } from 'react-redux'
import { compose } from 'redux'
import { throttleTime, filter, map } from 'rxjs/operators'
import type { Device, T } from 'types/common'
import type { ApplicationVersion, DeviceInfo } from '@ledgerhq/live-common/lib/types/manager'
@ -158,16 +157,9 @@ class AppsList extends PureComponent<Props, State> {
device: { path: devicePath },
deviceInfo: { targetId },
} = this.props
this.sub = cmd
.send({ app, devicePath, targetId })
.pipe(
filter(e => e.type === 'bulk-progress'), // only bulk progress interests the UI
throttleTime(100), // throttle to only emit 10 event/s max, to not spam the UI
map(e => e.progress), // extract a stream of progress percentage
)
.subscribe({
next: progress => {
this.setState({ progress })
this.sub = cmd.send({ app, devicePath, targetId }).subscribe({
next: patch => {
this.setState(patch)
},
complete: () => {
this.setState({ status: 'success' })

8
yarn.lock

@ -1725,10 +1725,10 @@
bindings "^1.3.0"
nan "^2.6.2"
"@ledgerhq/live-common@4.8.0-beta.13":
version "4.8.0-beta.13"
resolved "https://registry.yarnpkg.com/@ledgerhq/live-common/-/live-common-4.8.0-beta.13.tgz#64ecb2a8a8845f92519dfb9552623a42a9e3824e"
integrity sha512-Y66m+3q/6L8CAFUPXjlpS8jPE2168Y/X8JMC05voFKTC2U3Y1RGaRd/nEBA53Z2BFrbwZ2yIViylew4nFvH2Sg==
"@ledgerhq/live-common@4.8.0-beta.14":
version "4.8.0-beta.14"
resolved "https://registry.yarnpkg.com/@ledgerhq/live-common/-/live-common-4.8.0-beta.14.tgz#958bf811b2e1846fd3c218c863b1cfc729c2df19"
integrity sha512-gA2fvLbEfbXJ8IFm73Z236J3MrH7XQdFE3m12y3qWNYk4Bd1M1DWpIg4kFNPfxYTVaQ/Os0vJ08BOv9tj5lW9A==
dependencies:
"@aeternity/ledger-app-api" "0.0.4"
"@ledgerhq/hw-app-btc" "^4.32.0"

Loading…
Cancel
Save