Skip to content

Commit 0dec808

Browse files
authored
Reset sidebar on disconnect (#1328)
1 parent 10caf0a commit 0dec808

File tree

2 files changed

+18
-5
lines changed

2 files changed

+18
-5
lines changed

src/internal-plugins/app/lib/stores/instance-store.js

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,19 @@ const InstanceStore = Reflux.createStore({
2121
listenables: InstanceActions,
2222

2323
onActivated(appRegistry) {
24-
appRegistry.on('data-service-connected', (err, dataService) => {
25-
if (!err) {
26-
this.dataService = dataService;
27-
}
28-
});
24+
appRegistry.on('data-service-connected', this.onConnected.bind(this));
25+
appRegistry.on('data-service-disconnected', this.onDisconnected.bind(this));
26+
},
27+
28+
onConnected(err, dataService) {
29+
if (!err) {
30+
this.dataService = dataService;
31+
}
32+
},
33+
34+
onDisconnected() {
35+
const MongoDBInstance = require('../../../../app/models/mongodb-instance');
36+
app.state.instance = new MongoDBInstance();
2937
},
3038

3139
/**

src/internal-plugins/sidebar/lib/stores/index.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ const SidebarStore = Reflux.createStore({
2828
appRegistry.getStore('App.InstanceStore').listen(this.onInstanceChange.bind(this));
2929
appRegistry.on('collection-changed', this.onCollectionChanged.bind(this));
3030
appRegistry.on('database-changed', this.onDatabaseChanged.bind(this));
31+
appRegistry.on('data-service-disconnected', this.onDisconnected.bind(this));
3132
},
3233

3334
onCollectionChanged(ns) {
@@ -42,6 +43,10 @@ const SidebarStore = Reflux.createStore({
4243
});
4344
},
4445

46+
onDisconnected() {
47+
this.setState(this.getInitialState());
48+
},
49+
4550
/**
4651
* Initialize the Compass Sidebar store state.
4752
*

0 commit comments

Comments
 (0)