Browse Source

removed all calls to new API, app list working, can only install on firmware > 1.4

master
Valentin D. Pinkman 7 years ago
parent
commit
843c6a0191
No known key found for this signature in database GPG Key ID: E7D110669FFB8D3E
  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'
type Input = {
targetId: string | number,
}
// type Input = {
// targetId: string | number,
// }
type Input = *
type Result = *
const cmd: Command<Input, Result> = createCommand('listApps', ({ targetId }) =>
fromPromise(listApps(targetId)),
const cmd: Command<Input, Result> = createCommand('listApps', () =>
/* { targetId } */ fromPromise(listApps()),
)
export default cmd

6
src/components/ManagerPage/AppsList.js

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

100
src/components/ManagerPage/index.js

@ -1,58 +1,62 @@
// @flow
import React, { Fragment } from 'react'
import { translate } from 'react-i18next'
// import React, { Fragment } from 'react'
import React from 'react'
// import { translate } from 'react-i18next'
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 DeviceInfos from './DeviceInfos'
import FirmwareUpdate from './FirmwareUpdate'
// import FirmwareUpdate from './FirmwareUpdate'
import EnsureDevice from './EnsureDevice'
import EnsureDashboard from './EnsureDashboard'
import EnsureGenuine from './EnsureGenuine'
type DeviceInfo = {
targetId: number | string,
version: string,
final: boolean,
mcu: boolean,
}
type Props = {
t: T,
}
const ManagerPage = ({ t }: Props): Node => (
<Fragment>
<EnsureDevice>
{(device: Device) => (
<EnsureDashboard device={device}>
{(deviceInfo: DeviceInfo) => (
<Fragment>
{deviceInfo.mcu && <span> bootloader mode </span>}
{deviceInfo.final && <span> osu mode </span>}
{!deviceInfo.mcu &&
!deviceInfo.final && (
<EnsureGenuine device={device} t={t}>
<FirmwareUpdate
infos={{
targetId: deviceInfo.targetId,
version: deviceInfo.version,
}}
device={device}
t={t}
/>
<AppsList device={device} targetId={deviceInfo.targetId} />
</EnsureGenuine>
)}
</Fragment>
)}
</EnsureDashboard>
)}
</EnsureDevice>
</Fragment>
// import EnsureDashboard from './EnsureDashboard'
// import EnsureGenuine from './EnsureGenuine'
// type DeviceInfo = {
// targetId: number | string,
// version: string,
// final: boolean,
// mcu: boolean,
// }
// type Props = {
// t: T,
// }
// const ManagerPage = ({ t }: Props): Node => (
// <EnsureDevice>
// {(device: Device) => (
// <EnsureDashboard device={device}>
// {(deviceInfo: DeviceInfo) => (
// <Fragment>
// {deviceInfo.mcu && <span> bootloader mode </span>}
// {deviceInfo.final && <span> osu mode </span>}
// {!deviceInfo.mcu &&
// !deviceInfo.final && (
// <EnsureGenuine device={device} t={t}>
// <FirmwareUpdate
// infos={{
// targetId: deviceInfo.targetId,
// version: deviceInfo.version,
// }}
// device={device}
// t={t}
// />
// <AppsList device={device} targetId={deviceInfo.targetId} />
// </EnsureGenuine>
// )}
// </Fragment>
// )}
// </EnsureDashboard>
// )}
// </EnsureDevice>
// )
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
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 {
const { data: deviceData } = await axios.get(
`${API_BASE_URL}/device_versions_target_id/${targetId}`,
)
// const { data: deviceData } = await axios.get(
// `${API_BASE_URL}/device_versions_target_id/${targetId}`,
// )
const { data } = await axios.get('https://api.ledgerwallet.com/update/applications')
if (deviceData.name in data) {
return data[deviceData.name]
}
// if (deviceData.name in data) {
// return data[deviceData.name]
// }
return data['nanos-1.4']
} catch (err) {

Loading…
Cancel
Save