From 2e4e484fb3e931fe91060f8f0df0541ef1546789 Mon Sep 17 00:00:00 2001 From: meriadec Date: Tue, 25 Sep 2018 17:38:18 +0200 Subject: [PATCH 1/2] Visually disable the button if it is loading (ConfirmModal) --- src/components/base/Modal/ConfirmModal.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/components/base/Modal/ConfirmModal.js b/src/components/base/Modal/ConfirmModal.js index ea2842cd..c1c179c6 100644 --- a/src/components/base/Modal/ConfirmModal.js +++ b/src/components/base/Modal/ConfirmModal.js @@ -79,6 +79,7 @@ class ConfirmModal extends PureComponent { primary={!isDanger} danger={isDanger} isLoading={isLoading} + disabled={isLoading} > {realConfirmText} From 0b33390031ff5f67d74f87377e2235fb58211514 Mon Sep 17 00:00:00 2001 From: meriadec Date: Tue, 25 Sep 2018 17:39:21 +0200 Subject: [PATCH 2/2] Kill internal process before removing sqlite folder --- src/commands/index.js | 2 ++ src/commands/killInternalProcess.js | 18 ++++++++++++++++++ src/helpers/reset.js | 4 +++- 3 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 src/commands/killInternalProcess.js diff --git a/src/commands/index.js b/src/commands/index.js index 117a8b3f..fad516a6 100644 --- a/src/commands/index.js +++ b/src/commands/index.js @@ -15,6 +15,7 @@ import installFinalFirmware from 'commands/installFinalFirmware' import installMcu from 'commands/installMcu' import installOsuFirmware from 'commands/installOsuFirmware' import isDashboardOpen from 'commands/isDashboardOpen' +import killInternalProcess from 'commands/killInternalProcess' import libcoreGetFees from 'commands/libcoreGetFees' import libcoreGetVersion from 'commands/libcoreGetVersion' import libcoreScanAccounts from 'commands/libcoreScanAccounts' @@ -47,6 +48,7 @@ const all: Array> = [ installMcu, installOsuFirmware, isDashboardOpen, + killInternalProcess, libcoreGetFees, libcoreGetVersion, libcoreScanAccounts, diff --git a/src/commands/killInternalProcess.js b/src/commands/killInternalProcess.js new file mode 100644 index 00000000..428fecd4 --- /dev/null +++ b/src/commands/killInternalProcess.js @@ -0,0 +1,18 @@ +// @flow + +import { createCommand, Command } from 'helpers/ipc' +import { of } from 'rxjs' + +type Input = void +type Result = boolean + +const cmd: Command = createCommand('killInternalProcess', () => { + setTimeout(() => { + // we assume commands are run on the internal process + // special exit code for better identification + process.exit(42) + }) + return of(true) +}) + +export default cmd diff --git a/src/helpers/reset.js b/src/helpers/reset.js index 198d354a..051d4240 100644 --- a/src/helpers/reset.js +++ b/src/helpers/reset.js @@ -6,8 +6,10 @@ import resolveUserDataDirectory from 'helpers/resolveUserDataDirectory' import { disable as disableDBMiddleware } from 'middlewares/db' import db from 'helpers/db' import { delay } from 'helpers/promise' +import killInternalProcess from 'commands/killInternalProcess' -function resetLibcoreDatabase() { +async function resetLibcoreDatabase() { + await killInternalProcess.send().toPromise() const dbpath = path.resolve(resolveUserDataDirectory(), 'sqlite/') rimraf.sync(dbpath, { glob: false }) }