Browse Source

removed reading infos form device when fetching app list

master
Valentin D. Pinkman 7 years ago
parent
commit
833ee4a52c
No known key found for this signature in database GPG Key ID: E7D110669FFB8D3E
  1. 8
      src/commands/listApps.js
  2. 7
      src/components/ManagerPage/AppsList.js
  3. 8
      src/components/ManagerPage/index.js
  4. 6
      src/helpers/apps/listApps.js

8
src/commands/listApps.js

@ -3,16 +3,16 @@
import { createCommand, Command } from 'helpers/ipc'
import { fromPromise } from 'rxjs/observable/fromPromise'
import { withDevice } from 'helpers/deviceAccess'
import listApps from 'helpers/apps/listApps'
type Input = {
devicePath: string,
targetId: string | number,
}
type Result = *
const cmd: Command<Input, Result> = createCommand('devices', 'listApps', ({ devicePath }) =>
fromPromise(withDevice(devicePath)(transport => listApps(transport))),
const cmd: Command<Input, Result> = createCommand('devices', 'listApps', ({ targetId }) =>
fromPromise(listApps(targetId)),
)
export default cmd

7
src/components/ManagerPage/AppsList.js

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

8
src/components/ManagerPage/index.js

@ -8,7 +8,7 @@ import type { T } 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'
@ -30,15 +30,15 @@ const ManagerPage = ({ t }: Props): Node => (
{!deviceInfo.mcu &&
!deviceInfo.final && (
<EnsureGenuine device={device} t={t}>
<FirmwareUpdate
{/* <FirmwareUpdate
infos={{
targetId: deviceInfo.targetId,
version: deviceInfo.version,
}}
device={device}
t={t}
/>
<AppsList device={device} />
/> */}
<AppsList device={device} targetId={deviceInfo.targetId} />
</EnsureGenuine>
)}
</Fragment>

6
src/helpers/apps/listApps.js

@ -1,14 +1,10 @@
// @flow
import axios from 'axios'
import type Transport from '@ledgerhq/hw-transport'
import { getFirmwareInfo } from 'helpers/common'
const { API_BASE_URL } = process.env
export default async (transport: Transport<*>) => {
export default async (targetId: string | number) => {
try {
const { targetId } = await getFirmwareInfo(transport)
const { data: deviceData } = await axios.get(
`${API_BASE_URL}/device_versions_target_id/${targetId}`,
)

Loading…
Cancel
Save