Browse Source
check for device type before returning app list
master
Valentin D. Pinkman
7 years ago
No known key found for this signature in database
GPG Key ID: E7D110669FFB8D3E
7 changed files with
68 additions and
52 deletions
-
src/commands/installOsuFirmware.js
-
src/commands/listApps.js
-
src/components/ManagerPage/AppsList.js
-
src/components/ManagerPage/index.js
-
src/helpers/apps/listApps.js
-
src/internals/devices/index.js
-
src/internals/manager/index.js
|
@ -2,8 +2,8 @@ |
|
|
|
|
|
|
|
|
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 { withDevice } from 'helpers/deviceAccess' |
|
|
import installOsuFirmware from 'helpers/firmware/installOsuFirmware' |
|
|
import installOsuFirmware from 'helpers/firmware/installOsuFirmware' |
|
|
|
|
|
|
|
|
type Input = { |
|
|
type Input = { |
|
|
|
@ -3,13 +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, |
|
|
|
|
|
} |
|
|
type Result = * |
|
|
type Result = * |
|
|
|
|
|
|
|
|
const cmd: Command<Input, Result> = createCommand('manager', 'listApps', () => |
|
|
const cmd: Command<Input, Result> = createCommand('devices', 'listApps', ({ devicePath }) => |
|
|
fromPromise(listApps()), |
|
|
fromPromise(withDevice(devicePath)(transport => listApps(transport))), |
|
|
) |
|
|
) |
|
|
|
|
|
|
|
|
export default cmd |
|
|
export default cmd |
|
|
|
@ -69,11 +69,18 @@ class AppsList extends PureComponent<Props, State> { |
|
|
_unmounted = false |
|
|
_unmounted = false |
|
|
|
|
|
|
|
|
async fetchAppList() { |
|
|
async fetchAppList() { |
|
|
const appsList = CACHED_APPS || (await listApps.send().toPromise()) |
|
|
try { |
|
|
|
|
|
const { |
|
|
|
|
|
device: { path: devicePath }, |
|
|
|
|
|
} = 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' }) |
|
|
} |
|
|
} |
|
|
|
|
|
} catch (err) { |
|
|
|
|
|
this.setState({ status: 'error', error: err.message }) |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
handleInstallApp = (args: { app: any }) => async () => { |
|
|
handleInstallApp = (args: { app: any }) => async () => { |
|
|
|
@ -1,8 +1,9 @@ |
|
|
// @flow
|
|
|
// @flow
|
|
|
|
|
|
|
|
|
import React, { Component, Fragment } from 'react' |
|
|
import React, { Fragment } from 'react' |
|
|
import { translate } from 'react-i18next' |
|
|
import { translate } from 'react-i18next' |
|
|
|
|
|
|
|
|
|
|
|
import type { Node } from 'react' |
|
|
import type { T } from 'types/common' |
|
|
import type { T } from 'types/common' |
|
|
|
|
|
|
|
|
import AppsList from './AppsList' |
|
|
import AppsList from './AppsList' |
|
@ -16,13 +17,7 @@ type Props = { |
|
|
t: T, |
|
|
t: T, |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
type State = {} |
|
|
const ManagerPage = ({ t }: Props): Node => ( |
|
|
|
|
|
|
|
|
class ManagerPage extends Component<Props, State> { |
|
|
|
|
|
render() { |
|
|
|
|
|
const { t } = this.props |
|
|
|
|
|
|
|
|
|
|
|
return ( |
|
|
|
|
|
<Fragment> |
|
|
<Fragment> |
|
|
<EnsureDevice> |
|
|
<EnsureDevice> |
|
|
{device => ( |
|
|
{device => ( |
|
@ -52,8 +47,5 @@ class ManagerPage extends Component<Props, State> { |
|
|
)} |
|
|
)} |
|
|
</EnsureDevice> |
|
|
</EnsureDevice> |
|
|
</Fragment> |
|
|
</Fragment> |
|
|
) |
|
|
) |
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
export default translate()(ManagerPage) |
|
|
export default translate()(ManagerPage) |
|
|
|
@ -1,10 +1,23 @@ |
|
|
// @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 |
|
|
|
|
|
|
|
|
export default async () => { |
|
|
export default async (transport: Transport<*>) => { |
|
|
try { |
|
|
try { |
|
|
|
|
|
const { targetId } = await getFirmwareInfo(transport) |
|
|
|
|
|
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') |
|
|
const { data } = await axios.get('https://api.ledgerwallet.com/update/applications') |
|
|
|
|
|
|
|
|
|
|
|
if (deviceData.name in data) { |
|
|
|
|
|
return data[deviceData.name] |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
return data['nanos-1.4'] |
|
|
return data['nanos-1.4'] |
|
|
} catch (err) { |
|
|
} catch (err) { |
|
|
const error = Error(err.message) |
|
|
const error = Error(err.message) |
|
|
|
@ -15,6 +15,7 @@ import uninstallApp from 'commands/uninstallApp' |
|
|
import installOsuFirmware from 'commands/installOsuFirmware' |
|
|
import installOsuFirmware from 'commands/installOsuFirmware' |
|
|
import installFinalFirmware from 'commands/installFinalFirmware' |
|
|
import installFinalFirmware from 'commands/installFinalFirmware' |
|
|
import installMcu from 'commands/installMcu' |
|
|
import installMcu from 'commands/installMcu' |
|
|
|
|
|
import listApps from 'commands/listApps' |
|
|
|
|
|
|
|
|
export const commands: Array<Command<any, any>> = [ |
|
|
export const commands: Array<Command<any, any>> = [ |
|
|
getAddress, |
|
|
getAddress, |
|
@ -31,4 +32,5 @@ export const commands: Array<Command<any, any>> = [ |
|
|
installOsuFirmware, |
|
|
installOsuFirmware, |
|
|
installFinalFirmware, |
|
|
installFinalFirmware, |
|
|
installMcu, |
|
|
installMcu, |
|
|
|
|
|
listApps, |
|
|
] |
|
|
] |
|
|
|
@ -1,7 +1,6 @@ |
|
|
// @flow
|
|
|
// @flow
|
|
|
import type { Command } from 'helpers/ipc' |
|
|
import type { Command } from 'helpers/ipc' |
|
|
|
|
|
|
|
|
import listApps from 'commands/listApps' |
|
|
|
|
|
import getMemInfo from 'commands/getMemInfo' |
|
|
import getMemInfo from 'commands/getMemInfo' |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
@ -20,4 +19,4 @@ import getMemInfo from 'commands/getMemInfo' |
|
|
* |
|
|
* |
|
|
*/ |
|
|
*/ |
|
|
|
|
|
|
|
|
export const commands: Array<Command<any, any>> = [listApps, getMemInfo] |
|
|
export const commands: Array<Command<any, any>> = [getMemInfo] |
|
|