🐛 Fix PaneContainer::onDidStopChangingActivePaneItem()

We weren't ever dispatching this event! Oops XD
This commit is contained in:
Matthew Dapena-Tretter
2017-05-08 14:32:01 -07:00
parent 54d26c1223
commit 26d9579b0e
2 changed files with 44 additions and 0 deletions

View File

@@ -5,6 +5,7 @@ const ItemRegistry = require('./item-registry')
const PaneContainerElement = require('./pane-container-element')
const SERIALIZATION_VERSION = 1
const STOPPED_CHANGING_ACTIVE_PANE_ITEM_DELAY = 100
module.exports =
class PaneContainer {
@@ -15,6 +16,7 @@ class PaneContainer {
this.subscriptions = new CompositeDisposable()
this.itemRegistry = new ItemRegistry()
this.alive = true
this.stoppedChangingActivePaneItemTimeout = null
this.setRoot(new Pane({container: this, config: this.config, applicationDelegate, notificationManager, deserializerManager, viewRegistry: this.viewRegistry}))
this.didActivatePane(this.getRoot())
@@ -29,6 +31,7 @@ class PaneContainer {
destroy () {
this.alive = false
for (let pane of this.getRoot().getPanes()) { pane.destroy() }
this.cancelStoppedChangingActivePaneItemTimeout()
this.subscriptions.dispose()
this.emitter.dispose()
}
@@ -280,6 +283,21 @@ class PaneContainer {
didChangeActiveItemOnPane (pane, activeItem) {
if (pane === this.getActivePane()) {
this.emitter.emit('did-change-active-pane-item', activeItem)
this.cancelStoppedChangingActivePaneItemTimeout()
// `setTimeout()` isn't available during the snapshotting phase, but that's okay.
if (typeof setTimeout === 'function') {
this.stoppedChangingActivePaneItemTimeout = setTimeout(() => {
this.stoppedChangingActivePaneItemTimeout = null
this.emitter.emit('did-stop-changing-active-pane-item', activeItem)
}, STOPPED_CHANGING_ACTIVE_PANE_ITEM_DELAY)
}
}
}
cancelStoppedChangingActivePaneItemTimeout () {
if (this.stoppedChangingActivePaneItemTimeout != null) {
clearTimeout(this.stoppedChangingActivePaneItemTimeout)
}
}
}