From 8c6577658c6aaa3068c3b684cdbb91e9f14d5930 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABtan=20Renaudeau?= Date: Wed, 20 Jun 2018 19:42:28 +0200 Subject: [PATCH] Fix lint & actually return a correct observable from promise --- src/commands/libcoreHardReset.js | 11 ++++++----- src/helpers/hardReset.js | 4 +++- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/commands/libcoreHardReset.js b/src/commands/libcoreHardReset.js index 7e148a1a..e8cad9b4 100644 --- a/src/commands/libcoreHardReset.js +++ b/src/commands/libcoreHardReset.js @@ -1,20 +1,21 @@ // @flow import { createCommand } from 'helpers/ipc' -import { Observable } from 'rxjs' +import { fromPromise } from 'rxjs/observable/fromPromise' import withLibcore from 'helpers/withLibcore' import createCustomErrorClass from 'helpers/createCustomErrorClass' + const HardResetFail = createCustomErrorClass('HardResetFail') const cmd = createCommand('libcoreHardReset', () => - Observable.create(o => { + fromPromise( withLibcore(async core => { const result = await core.getPoolInstance().eraseDataSince(new Date(0)) - if (result != core.ERROR_CODE.FUTURE_WAS_SUCCESSFULL) { + if (result !== core.ERROR_CODE.FUTURE_WAS_SUCCESSFULL) { throw new HardResetFail(`Hard reset fail with ${result} (check core.ERROR_CODE)`) } - }) - }), + }), + ), ) export default cmd diff --git a/src/helpers/hardReset.js b/src/helpers/hardReset.js index b2fc3514..2ae2589e 100644 --- a/src/helpers/hardReset.js +++ b/src/helpers/hardReset.js @@ -8,7 +8,9 @@ export default async function hardReset() { // TODO: wait for the libcoreHardReset to be finished // actually, libcore doesnt goes back to js thread await libcoreHardReset.send() - //await Promise.race([libcoreHardReset.send().toPromise(), delay(500)]) + + // await Promise.race([libcoreHardReset.send().toPromise(), delay(500)]) + disableDBMiddleware() db.resetAll() await delay(500)