[Search] Generic indexes once

Changed the generic search provider to index the
file tree only once when it is initially called.
This assumes that the contents of the file tree
will not change significantly within the course
of a use session (and some changes may be caught
by other search providers).
This commit is contained in:
slhale 2015-07-29 10:26:24 -07:00
parent ce433a01b2
commit 639cf1cf59
2 changed files with 16 additions and 1 deletions

View File

@ -181,14 +181,30 @@ define(
maxResults = DEFAULT_MAX_RESULTS;
}
/*
// Get items list
return getItems(timeout).then(function () {
// Then get the worker to search through it
workerSearch(input, maxResults, timestamp);
return; // There's nothing we need to return here
});
*/
// Instead, assume that the items have already been indexed, and
// just send the query to the worker.
workerSearch(input, maxResults, timestamp);
return;
}
// Index the tree's contents once at the beginning
// TODO: Is this a good assumption that the tree's contents will not
// change often enough?
// TODO: This makes the timeout parameter that queryGeneric takes
// useless. See if timing out worker is an idea that works.
getItems();
return {
/**
* Searches through the filetree for domain objects which match

View File

@ -34,7 +34,6 @@
// Helper function for index()
function conainsItem(id) {
var i;
for (i = 0; i < indexedItems.length; i += 1) {
if (indexedItems[i].id === id) {
return true;