From 34f090e868194279c5a68d7201be69e294928e69 Mon Sep 17 00:00:00 2001 From: yann300 Date: Thu, 19 Sep 2019 23:21:51 +0200 Subject: [PATCH 1/3] if electron try to load remixd --- src/app.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/app.js b/src/app.js index 97c15480c0..36c14f75b5 100644 --- a/src/app.js +++ b/src/app.js @@ -346,4 +346,8 @@ Please make a backup of your contracts and start using http://remix.ethereum.org } }) } + + if (isElectron()) { + appManager.activate(['remixd']) + } } From 6af8b258cb58606e0f1e8c8f150e1aa43cf4aa72 Mon Sep 17 00:00:00 2001 From: yann300 Date: Thu, 19 Sep 2019 23:22:44 +0200 Subject: [PATCH 2/3] keep a list of plugin we don't want to autoload && and add remixd to it. --- src/remixAppManager.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/remixAppManager.js b/src/remixAppManager.js index c8cc43a0b1..6130201cbc 100644 --- a/src/remixAppManager.js +++ b/src/remixAppManager.js @@ -19,11 +19,14 @@ export class RemixAppManager extends PluginEngine { constructor (plugins) { super(plugins, settings) this.event = new EventEmitter() + this.donotAutoReload = ['remixd'] // that would be a bad practice to force loading some plugins at page load. this.registered = {} } onActivated (plugin) { - localStorage.setItem('workspace', JSON.stringify(this.actives)) + if (!this.donotAutoReload.includes(plugin.name)) { + localStorage.setItem('workspace', JSON.stringify(this.actives)) + } this.event.emit('activate', plugin.name) } From a4e24d2279cf928d7799d1adfdc94851ffdb35d5 Mon Sep 17 00:00:00 2001 From: yann300 Date: Thu, 19 Sep 2019 23:23:27 +0200 Subject: [PATCH 3/3] if we are in electron, don't display remixd modal --- src/app/files/remixd-handle.js | 31 ++++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/src/app/files/remixd-handle.js b/src/app/files/remixd-handle.js index b64799c6ed..62a9ecf515 100644 --- a/src/app/files/remixd-handle.js +++ b/src/app/files/remixd-handle.js @@ -1,3 +1,4 @@ +import isElectron from 'is-electron' import { Plugin } from '@remixproject/engine' import * as packageJson from '../../../package.json' var yo = require('yo-yo') @@ -55,28 +56,30 @@ export class RemixdHandle extends Plugin { * @param {String} txHash - hash of the transaction */ connectToLocalhost () { + let connection = (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() + } + } if (this.locahostProvider.isConnected()) { this.locahostProvider.close((error) => { if (error) console.log(error) }) - } else { + } else if (!isElectron()) { + // warn the user only if he/she is in the browser context 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() - } - }) + this.locahostProvider.init((error) => connection(error)) } }, { label: 'Cancel', @@ -85,6 +88,8 @@ export class RemixdHandle extends Plugin { } } ) + } else { + this.locahostProvider.init((error) => connection(error)) } } }