Browse Source

New version of QRStream

gre-patch-1
Gaëtan Renaudeau 6 years ago
parent
commit
c082fad263
No known key found for this signature in database GPG Key ID: 7B66B85F042E5451
  1. 2
      package.json
  2. 36
      src/components/QRCodeExporter.js
  3. 2
      src/components/base/QRCode/index.js
  4. 11
      src/reducers/settings.js
  5. 2300
      yarn.lock

2
package.json

@ -40,7 +40,7 @@
"@ledgerhq/hw-transport": "^4.13.0",
"@ledgerhq/hw-transport-node-hid": "4.22.0",
"@ledgerhq/ledger-core": "2.0.0-rc.7",
"@ledgerhq/live-common": "^3.7.1",
"@ledgerhq/live-common": "3.8.0-beta.7",
"animated": "^0.2.2",
"async": "^2.6.1",
"axios": "^0.18.0",

36
src/components/QRCodeExporter.js

@ -1,24 +1,28 @@
// @flow
import React, { PureComponent } from 'react'
import { Buffer } from 'buffer'
import { createSelector } from 'reselect'
import { connect } from 'react-redux'
import { accountsSelector } from 'reducers/accounts'
import { exportSettingsSelector } from 'reducers/settings'
import { makeChunks } from '@ledgerhq/live-common/lib/bridgestream/exporter'
import QRCode from './base/QRCode'
const mapStateToProps = createSelector(accountsSelector, accounts => ({
chunks: makeChunks({
accounts,
exporterName: 'desktop',
exporterVersion: __APP_VERSION__,
pad: true,
const mapStateToProps = createSelector(
accountsSelector,
exportSettingsSelector,
(accounts, settings) => ({
chunks: makeChunks({
accounts,
settings,
exporterName: 'desktop',
exporterVersion: __APP_VERSION__,
chunkSize: 120,
}),
}),
}))
const LOW_FPS = 2
const HIGH_FPS = 8
)
class QRCodeExporter extends PureComponent<
{
@ -36,18 +40,16 @@ class QRCodeExporter extends PureComponent<
state = {
frame: 0,
fps: HIGH_FPS,
fps: 5,
}
componentDidMount() {
console.log(`BRIDGESTREAM_DATA=${btoa(JSON.stringify(this.props.chunks))}`) // eslint-disable-line
const BRIDGESTREAM_DATA = Buffer.from(JSON.stringify(this.props.chunks)).toString('base64')
console.log(`BRIDGESTREAM_DATA=${BRIDGESTREAM_DATA}`) // eslint-disable-line
const nextFrame = ({ frame, fps }, { chunks }) => {
const nextFrame = ({ frame }, { chunks }) => {
frame = (frame + 1) % chunks.length
return {
frame,
fps: frame === 0 ? (fps === LOW_FPS ? HIGH_FPS : LOW_FPS) : fps,
}
return { frame }
}
let lastT

2
src/components/base/QRCode/index.js

@ -38,7 +38,7 @@ class QRCode extends PureComponent<Props> {
}
render() {
return <canvas ref={n => (this._canvas = n)} />
return <canvas style={{ cursor: 'none' }} ref={n => (this._canvas = n)} />
}
}

11
src/reducers/settings.js

@ -224,4 +224,15 @@ export const selectedTimeRangeSelector = (state: State) => state.settings.select
export const hasCompletedOnboardingSelector = (state: State) =>
state.settings.hasCompletedOnboarding
export const exportSettingsSelector = createSelector(
counterValueCurrencySelector,
counterValueExchangeSelector,
state => state.settings.currenciesSettings,
(counterValueCurrency, counterValueExchange, currenciesSettings) => ({
counterValue: counterValueCurrency.ticker,
counterValueExchange,
currenciesSettings,
}),
)
export default handleActions(handlers, INITIAL_STATE)

2300
yarn.lock

File diff suppressed because it is too large
Loading…
Cancel
Save