[Search] Items list updating

The search results now updates the items
list when called to make sure that it gets
all of the recently added items.
This commit is contained in:
shale 2015-07-10 12:53:12 -07:00
parent efba0f0236
commit b5756d2b99

View File

@ -85,24 +85,23 @@ define(function () {
// Search through items for items which contain the search term
// in the title
function search(term) {
console.log('search called');
console.log('search term ', term);
console.log('search called, with term ', term);
var searchResults = [],
itemsLength,
i;
// refresh items list
listify();
itemsLength = $scope.items.length; // Slight time optimization
for (i = 0; i < itemsLength; i += 1) {
console.log('items[', i, '].getModel', $scope.items[i].getModel());
if ($scope.items[i].getModel().name.includes(term)) {
searchResults.push($scope.items[i]);
return listify().then( function () {
itemsLength = $scope.items.length; // Slight time optimization
for (i = 0; i < itemsLength; i += 1) {
console.log('items[', i, '].getModel', $scope.items[i].getModel());
if ($scope.items[i].getModel().name.includes(term)) {
searchResults.push($scope.items[i]);
}
}
}
console.log('search results ', searchResults);
$scope.results = searchResults; // Somewhat redundant
return searchResults;
console.log('search results ', searchResults);
$scope.results = searchResults; // Somewhat redundant
return searchResults;
});
}
// When the search view is opened, call listify()