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

7
src/components/ManagerPage/AppsList.js

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

6
src/helpers/apps/listApps.js

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

Loading…
Cancel
Save