From 5c0f6c2f69015b15466f9c115380f4d6b70085b9 Mon Sep 17 00:00:00 2001 From: "Valentin D. Pinkman" Date: Wed, 30 May 2018 13:32:18 +0200 Subject: [PATCH] fix uninstall app --- src/components/ManagerPage/AppsList.js | 18 +++++++++++++++--- src/helpers/apps/uninstallApp.js | 7 ++++++- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/src/components/ManagerPage/AppsList.js b/src/components/ManagerPage/AppsList.js index 4388182d..9971e69e 100644 --- a/src/components/ManagerPage/AppsList.js +++ b/src/components/ManagerPage/AppsList.js @@ -6,6 +6,7 @@ import { translate } from 'react-i18next' import listApps from 'commands/listApps' import installApp from 'commands/installApp' +import uninstallApp from 'commands/uninstallApp' import Box from 'components/base/Box' import Modal, { ModalBody } from 'components/base/Modal' @@ -97,8 +98,19 @@ class AppsList extends PureComponent { } } - handleUninstallApp = (/* args: { app: any } */) => () => { - /* TODO */ + handleUninstallApp = (args: { app: any }) => async () => { + const appParams = args.app + this.setState({ status: 'busy' }) + try { + const { + device: { path: devicePath }, + } = this.props + const data = { appParams, devicePath } + await uninstallApp.send(data).toPromise() + this.setState({ status: 'success' }) + } catch (err) { + this.setState({ status: 'error', error: err.message }) + } } handleCloseModal = () => this.setState({ status: 'idle' }) @@ -114,7 +126,7 @@ class AppsList extends PureComponent { version={`Version ${c.version}`} icon={ICONS_FALLBACK[c.icon] || c.icon} onInstall={this.handleInstallApp(c)} - onUninstall={this.handleUninstallApp()} + onUninstall={this.handleUninstallApp(c)} /> ))} , { appParams }: { appParams: LedgerScriptParams }, ): Promise { - return createSocketDialog(transport, '/update/install', appParams) + const params = { + ...appParams, + firmware: appParams.delete, + firmwareKey: appParams.deleteKey, + } + return createSocketDialog(transport, '/update/install', params) }