Browse Source

Merge pull request #416 from valpinkman/fix-app-for-test-release

temporarily disable the new API calls for firmware (current limitation: apps can install on firmware > 1.4)
master
Gaëtan Renaudeau 7 years ago
committed by GitHub
parent
commit
06f4323fe1
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 11
      src/commands/listApps.js
  2. 6
      src/components/ManagerPage/AppsList.js
  3. 100
      src/components/ManagerPage/index.js
  4. 16
      src/helpers/apps/listApps.js

11
src/commands/listApps.js

@ -5,14 +5,15 @@ import { fromPromise } from 'rxjs/observable/fromPromise'
import listApps from 'helpers/apps/listApps' import listApps from 'helpers/apps/listApps'
type Input = { // type Input = {
targetId: string | number, // targetId: string | number,
} // }
type Input = *
type Result = * type Result = *
const cmd: Command<Input, Result> = createCommand('listApps', ({ targetId }) => const cmd: Command<Input, Result> = createCommand('listApps', () =>
fromPromise(listApps(targetId)), /* { targetId } */ fromPromise(listApps()),
) )
export default cmd export default cmd

6
src/components/ManagerPage/AppsList.js

@ -43,7 +43,7 @@ type LedgerApp = {
type Props = { type Props = {
device: Device, device: Device,
targetId: string | number, // targetId: string | number,
t: T, t: T,
} }
@ -72,8 +72,8 @@ class AppsList extends PureComponent<Props, State> {
async fetchAppList() { async fetchAppList() {
try { try {
const { targetId } = this.props // const { targetId } = this.props
const appsList = CACHED_APPS || (await listApps.send({ targetId }).toPromise()) const appsList = CACHED_APPS || (await listApps.send().toPromise())
CACHED_APPS = appsList CACHED_APPS = appsList
if (!this._unmounted) { if (!this._unmounted) {
this.setState({ appsList, status: 'idle' }) this.setState({ appsList, status: 'idle' })

100
src/components/ManagerPage/index.js

@ -1,58 +1,62 @@
// @flow // @flow
import React, { Fragment } from 'react' // import React, { Fragment } from 'react'
import { translate } from 'react-i18next' import React from 'react'
// import { translate } from 'react-i18next'
import type { Node } from 'react' import type { Node } from 'react'
import type { T, Device } from 'types/common' // import type { T, Device } from 'types/common'
import type { Device } from 'types/common'
import AppsList from './AppsList' import AppsList from './AppsList'
// import DeviceInfos from './DeviceInfos' // import DeviceInfos from './DeviceInfos'
import FirmwareUpdate from './FirmwareUpdate' // import FirmwareUpdate from './FirmwareUpdate'
import EnsureDevice from './EnsureDevice' import EnsureDevice from './EnsureDevice'
import EnsureDashboard from './EnsureDashboard' // import EnsureDashboard from './EnsureDashboard'
import EnsureGenuine from './EnsureGenuine' // import EnsureGenuine from './EnsureGenuine'
type DeviceInfo = { // type DeviceInfo = {
targetId: number | string, // targetId: number | string,
version: string, // version: string,
final: boolean, // final: boolean,
mcu: boolean, // mcu: boolean,
} // }
type Props = { // type Props = {
t: T, // t: T,
} // }
const ManagerPage = ({ t }: Props): Node => ( // const ManagerPage = ({ t }: Props): Node => (
<Fragment> // <EnsureDevice>
<EnsureDevice> // {(device: Device) => (
{(device: Device) => ( // <EnsureDashboard device={device}>
<EnsureDashboard device={device}> // {(deviceInfo: DeviceInfo) => (
{(deviceInfo: DeviceInfo) => ( // <Fragment>
<Fragment> // {deviceInfo.mcu && <span> bootloader mode </span>}
{deviceInfo.mcu && <span> bootloader mode </span>} // {deviceInfo.final && <span> osu mode </span>}
{deviceInfo.final && <span> osu mode </span>} // {!deviceInfo.mcu &&
{!deviceInfo.mcu && // !deviceInfo.final && (
!deviceInfo.final && ( // <EnsureGenuine device={device} t={t}>
<EnsureGenuine device={device} t={t}> // <FirmwareUpdate
<FirmwareUpdate // infos={{
infos={{ // targetId: deviceInfo.targetId,
targetId: deviceInfo.targetId, // version: deviceInfo.version,
version: deviceInfo.version, // }}
}} // device={device}
device={device} // t={t}
t={t} // />
/> // <AppsList device={device} targetId={deviceInfo.targetId} />
<AppsList device={device} targetId={deviceInfo.targetId} /> // </EnsureGenuine>
</EnsureGenuine> // )}
)} // </Fragment>
</Fragment> // )}
)} // </EnsureDashboard>
</EnsureDashboard> // )}
)} // </EnsureDevice>
</EnsureDevice> // )
</Fragment>
const ManagerPage = (): Node => (
<EnsureDevice>{(device: Device) => <AppsList device={device} />}</EnsureDevice>
) )
export default translate()(ManagerPage) export default ManagerPage

16
src/helpers/apps/listApps.js

@ -1,18 +1,18 @@
// @flow // @flow
import axios from 'axios' import axios from 'axios'
const { API_BASE_URL } = process.env // const { API_BASE_URL } = process.env
export default async (targetId: string | number) => { export default async (/* targetId: string | number */) => {
try { try {
const { data: deviceData } = await axios.get( // const { data: deviceData } = await axios.get(
`${API_BASE_URL}/device_versions_target_id/${targetId}`, // `${API_BASE_URL}/device_versions_target_id/${targetId}`,
) // )
const { data } = await axios.get('https://api.ledgerwallet.com/update/applications') const { data } = await axios.get('https://api.ledgerwallet.com/update/applications')
if (deviceData.name in data) { // if (deviceData.name in data) {
return data[deviceData.name] // return data[deviceData.name]
} // }
return data['nanos-1.4'] return data['nanos-1.4']
} catch (err) { } catch (err) {

Loading…
Cancel
Save