Skip to content

Commit ebcec30

Browse files
rueckstiesskangas
authored andcommitted
INT-1425 fix feature tour
(cherry picked from commit 7b719f7)
1 parent 3f401b7 commit ebcec30

File tree

1 file changed

+25
-10
lines changed

1 file changed

+25
-10
lines changed

src/app/tour/index.js

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ var TAB_KEY = 9;
1717
var ENTER_KEY = 13;
1818
var SPACE_KEY = 32;
1919

20-
2120
/**
2221
* The feature tour highlights some signature features of MongoDB Compass.
2322
* When Compass is started for the first time, it shows all the features in
@@ -42,7 +41,15 @@ var FEATURES = require('./features');
4241
var TourView = View.extend({
4342
session: {
4443
body: 'any',
45-
features: 'array',
44+
features: {
45+
type: 'array',
46+
required: false,
47+
default: undefined
48+
},
49+
force: {
50+
type: 'boolean',
51+
default: false
52+
},
4653
tourCount: {
4754
type: 'number',
4855
default: 0
@@ -58,9 +65,9 @@ var TourView = View.extend({
5865
template: indexTemplate,
5966
derived: {
6067
previousVersion: {
61-
deps: ['app.preferences.lastKnownVersion'],
68+
deps: ['app.preferences.showFeatureTour'],
6269
fn: function() {
63-
return app.preferences.lastKnownVersion;
70+
return app.preferences.showFeatureTour;
6471
}
6572
},
6673
title: {
@@ -95,13 +102,21 @@ var TourView = View.extend({
95102
this.showPreviousFeature();
96103
}
97104
},
98-
initialize: function(options) {
105+
initialize: function() {
99106
this.onKeyPress = this.onKeyPress.bind(this);
100-
this.features = _.filter(FEATURES, function(feature) {
101-
return (options.force && feature.initial)
102-
|| (this.previousVersion === '0.0.0' && feature.initial)
103-
|| (this.previousVersion !== '0.0.0' && semver.gt(feature.version, this.previousVersion));
104-
}.bind(this));
107+
this._getFeatures();
108+
},
109+
_getFeatures: function() {
110+
var model = this;
111+
if (_.isArray(model.features)) {
112+
return model.features;
113+
}
114+
model.features = _.filter(FEATURES, function(feature) {
115+
return (model.force && feature.initial)
116+
|| (model.previousVersion === '0.0.0' && feature.initial)
117+
|| (model.previousVersion !== '0.0.0' && semver.gt(feature.version, model.previousVersion));
118+
});
119+
return model.features;
105120
},
106121
render: function() {
107122
this.renderWithTemplate(this);

0 commit comments

Comments
 (0)