Memoize disabled for all the other operations too

see 81127d71f
This commit is contained in:
Bryan Housel
2019-04-10 11:28:41 -04:00
parent 81127d71f3
commit f309e925d8
13 changed files with 193 additions and 84 deletions
+9 -5
View File
@@ -10,6 +10,7 @@ export function operationSplit(selectedIDs, context) {
var entityID = vertices[0];
var action = actionSplit(entityID);
var ways = [];
var _disabled;
if (vertices.length === 1) {
if (entityID && selectedIDs.length > 1) {
@@ -32,13 +33,16 @@ export function operationSplit(selectedIDs, context) {
operation.disabled = function() {
var reason = action.disabled(context.graph());
if (reason) {
return reason;
if (_disabled !== undefined) return _disabled;
_disabled = action.disabled(context.graph());
if (_disabled) {
return _disabled;
} else if (selectedIDs.some(context.hasHiddenConnections)) {
return 'connected_to_hidden';
return _disabled = 'connected_to_hidden';
}
return false;
return _disabled = false;
};