From 40c45077ef3a0bfdd3c49eedf47fd18dcb38d0f6 Mon Sep 17 00:00:00 2001 From: muxator Date: Sat, 9 Feb 2019 01:15:50 +0100 Subject: [PATCH] db/GroupManager.js: factored out a variable Extracted from Ray's work. --- src/node/db/GroupManager.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/node/db/GroupManager.js b/src/node/db/GroupManager.js index 985883203..88aa8aa04 100644 --- a/src/node/db/GroupManager.js +++ b/src/node/db/GroupManager.js @@ -122,7 +122,9 @@ exports.deleteGroup = function(groupID, callback) if (ERR(err, callback)) return; groups = groups? groups.groupIDs : []; - if (groups.indexOf(groupID) === -1) { + let index = groups.indexOf(groupID); + + if (index === -1) { // it's not listed callback(); @@ -130,7 +132,7 @@ exports.deleteGroup = function(groupID, callback) } // remove from the list - groups.splice(groups.indexOf(groupID), 1); + groups.splice(index, 1); // store empty group list if (groups.length == 0) {