Skip to content

Commit

Permalink
Address PR feedback by reducing code changes to core history module.
Browse files Browse the repository at this point in the history
  • Loading branch information
Bonkles committed Dec 9, 2019
1 parent 0558b29 commit 6c4e1c4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 13 deletions.
11 changes: 0 additions & 11 deletions modules/core/history.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,17 +125,6 @@ export function coreHistory(context) {
},


countAIFeaturesAdded: function() {
var count = 0;
for (var i = 0; i <= _index; i++) {
if (_stack[i].annotation && _stack[i].annotation.type === 'fb_accept_feature') {
count++;
}
}
return count;
},


peekAllAnnotations: function() {
var result = [];
for (var i = 0; i <= _index; i++) {
Expand Down
12 changes: 10 additions & 2 deletions modules/ui/fb_feature_picker.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,16 @@ export function uiFbFeaturePicker(context, keybinding) {
var gpxInUrl = utilStringQs(window.location.hash).gpx;
if (gpxInUrl) return false;

var numAiFeatures = context.history().countAIFeaturesAdded();
return numAiFeatures >= AI_FEATURES_LIMIT_NON_TM_MODE;
var aiFeatures = context.history().peekAllAnnotations();

var aiFeatureCount = 0;
for (var i = 0; i <= aiFeatures.length; i++) {
if (aiFeatures[i] && aiFeatures[i].type === 'fb_accept_feature') {
aiFeatureCount++;
}
}

return aiFeatureCount >= AI_FEATURES_LIMIT_NON_TM_MODE;
}


Expand Down

0 comments on commit 6c4e1c4

Please sign in to comment.