From 54af6f6fe95dacd595c38fa82121aee8ab5b17fd Mon Sep 17 00:00:00 2001 From: LianaHus Date: Tue, 9 Apr 2019 15:26:11 +0200 Subject: [PATCH] deactivate remixd plugin if canceled or error --- src/app/files/remixd-handle.js | 25 +++++++++++++++++++++++-- src/remixAppManager.js | 7 ++++++- 2 files changed, 29 insertions(+), 3 deletions(-) diff --git a/src/app/files/remixd-handle.js b/src/app/files/remixd-handle.js index 1cc02c28f4..19fd6a7cc0 100644 --- a/src/app/files/remixd-handle.js +++ b/src/app/files/remixd-handle.js @@ -1,7 +1,10 @@ import { ApiFactory } from 'remix-plugin' +let globalRegistry = require('../../global/registry') var yo = require('yo-yo') var modalDialog = require('../ui/modaldialog') +var modalDialogCustom = require('../ui/modal-dialog-custom') + var csjs = require('csjs-inject') @@ -43,6 +46,11 @@ export class RemixdHandle extends ApiFactory { this.connectToLocalhost() } + canceled () { + let appManager = globalRegistry.get('appmanager').api + appManager.ensureDeactivated('remixd') + } + /** * connect to localhost if no connection and render the explorer * disconnect from localhost if connected and remove the explorer @@ -55,17 +63,30 @@ export class RemixdHandle extends ApiFactory { if (error) console.log(error) }) } else { - modalDialog('Connect to localhost', remixdDialog(), + modalDialog( + 'Connect to localhost', + remixdDialog(), { label: 'Connect', fn: () => { this.locahostProvider.init((error) => { if (error) { console.log(error) + modalDialogCustom.alert( + 'Cannot connect to the remixd daemon.' + + 'Please make sure you have the remixd running in the background.' + ) + this.canceled() } else { this.fileSystemExplorer.ensureRoot() } }) - }} + } + }, + { label: 'Cancel', + fn: () => { + this.canceled() + } + } ) } } diff --git a/src/remixAppManager.js b/src/remixAppManager.js index 34de083d79..697229973b 100644 --- a/src/remixAppManager.js +++ b/src/remixAppManager.js @@ -21,6 +21,11 @@ export class RemixAppManager extends AppManagerApi { this.event.emit('ensureActivated', apiName) } + ensureDeactivated (apiName) { + if (this.store.isActive(apiName)) this.deactivateOne(apiName) + this.event.emit('ensureDeactivated', apiName) + } + proxy () { // that's temporary. should be removed when we can have proper notification registration return this.data.proxy @@ -82,4 +87,4 @@ export class RemixAppManager extends AppManagerApi { new Plugin(vyper) ] } -} +} \ No newline at end of file