From 5367933bd523dd353fc4379bc450161e3d66de26 Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Wed, 5 Sep 2018 13:05:00 -0400 Subject: [PATCH] move active events --- src/app.js | 2 +- src/app/debugger/debugger.js | 10 ---------- src/app/debugger/debuggerUI.js | 20 ++++++++++++++++++++ src/app/tabs/debugger-tab.js | 7 ++++--- 4 files changed, 25 insertions(+), 14 deletions(-) diff --git a/src/app.js b/src/app.js index 4077ae1846..fe3f6b1c08 100644 --- a/src/app.js +++ b/src/app.js @@ -230,7 +230,7 @@ class App { } runCompiler () { const self = this - if (self._components.righthandpanel.debugger().isActive) return + if (self._components.righthandpanel.debugger().isDebuggerActive()) return self._components.fileManager.saveCurrentFile() self._components.editorpanel.getEditor().clearAnnotations() diff --git a/src/app/debugger/debugger.js b/src/app/debugger/debugger.js index b63294b800..4c38613bde 100644 --- a/src/app/debugger/debugger.js +++ b/src/app/debugger/debugger.js @@ -35,7 +35,6 @@ function Debugger (container, sourceHighlighter, localRegistry) { // TODO: render doesn't exist anymore container.appendChild(this.debugger_ui.render()) // - this.isActive = false this.breakPointManager = new remixLib.code.BreakpointManager(this.debugger, (sourceLocation) => { return self._deps.offsetToLineColumnConverter.offsetToLineColumn(sourceLocation, sourceLocation.file, this._deps.compiler.lastCompilationResult.source.sources, this._deps.compiler.lastCompilationResult.data.sources) @@ -58,15 +57,6 @@ function Debugger (container, sourceHighlighter, localRegistry) { self.switchProvider(context) }) - this.debugger.event.register('newTraceLoaded', this, function () { - self.isActive = true - }) - - this.debugger.event.register('traceUnloaded', this, function () { - self._components.sourceHighlighter.currentSourceLocation(null) - self.isActive = false - }) - // unload if a file has changed (but not if tabs were switched) self._deps.editor.event.register('contentChanged', function () { self.debugger.unLoad() diff --git a/src/app/debugger/debuggerUI.js b/src/app/debugger/debuggerUI.js index e570e7a566..1bfc11279c 100644 --- a/src/app/debugger/debuggerUI.js +++ b/src/app/debugger/debuggerUI.js @@ -10,11 +10,31 @@ class DebuggerUI { this.transactionDebugger.addProvider('injected', executionContext.internalWeb3()) this.transactionDebugger.addProvider('web3', executionContext.internalWeb3()) this.transactionDebugger.switchProvider(executionContext.getProvider()) + + this.isActive = false + + this.listenToEvents() + } + + listenToEvents () { + const self = this + this.transactionDebugger.debugger.event.register('newTraceLoaded', this, function () { + self.isActive = true + }) + + this.transactionDebugger.debugger.event.register('traceUnloaded', this, function () { + self._components.sourceHighlighter.currentSourceLocation(null) + self.isActive = false + }) } view () { return this.transactionDebugger } + + isDebuggerActive () { + return this.isActive + } } module.exports = DebuggerUI diff --git a/src/app/tabs/debugger-tab.js b/src/app/tabs/debugger-tab.js index bbe4738dfb..9d9ed3b7b8 100644 --- a/src/app/tabs/debugger-tab.js +++ b/src/app/tabs/debugger-tab.js @@ -38,13 +38,14 @@ class DebuggerTab {
` - let debuggerUI = new DebuggerUI(self._view.el.querySelector('#debugger')) - self._view.transactionDebugger = debuggerUI.view() + this.debuggerUI = new DebuggerUI(self._view.el.querySelector('#debugger')) + self._view.transactionDebugger = this.debuggerUI.view() return self._view.el } debugger () { - return this._view.transactionDebugger + // return this._view.transactionDebugger + return this.debuggerUI } }