From 33b30f75838468b4278ee88932a906193f83559c Mon Sep 17 00:00:00 2001 From: shale Date: Fri, 10 Jul 2015 15:16:28 -0700 Subject: [PATCH] [Search] Removed unnecissary variable Removed $scope.items, because it was unnecissary. --- .../features/search/src/SearchController.js | 25 ++++++++----------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/platform/features/search/src/SearchController.js b/platform/features/search/src/SearchController.js index 9dce798660..a425124bf6 100644 --- a/platform/features/search/src/SearchController.js +++ b/platform/features/search/src/SearchController.js @@ -76,7 +76,6 @@ define(function () { return objectService.getObjects(['mine']).then(function (objects) { return listHelper(objects.mine).then(function (c) { console.log('final result ', c); - $scope.items = c; // Somewhat redundant return c; }); }); @@ -96,37 +95,33 @@ define(function () { term = term.toLocaleLowerCase(); } - // Refresh items list - return listify().then( function () { - // Slight time optimization - itemsLength = $scope.items.length; + // Get items list + return listify().then(function (items) { + // (slight time optimization) + itemsLength = items.length; + // Then filter through the items list for (i = 0; i < itemsLength; i += 1) { - itemModel = $scope.items[i].getModel(); + itemModel = items[i].getModel(); itemName = itemModel.name.toLocaleLowerCase(); // Include any matching items, except folders if (itemName.includes(term) && itemModel.type !== 'folder') { - searchResults.push($scope.items[i]); + searchResults.push(items[i]); } } - $scope.results = searchResults; // Somewhat redundant + $scope.results = searchResults; // Some redundancy return searchResults; }); } - // When the search view is opened, call listify() - // When the search button is pressed, call search() - - $scope.items = listify(); $scope.results = search(); return { search: search, - /** - * Check to see if there are any search results to display. - */ + + // Check to see if there are any search results to display. areResults: function () { return $scope.results.length !== 0; }