[Search] Generic search roots constant

Made a constant for the generic search roots,
rather than depending on roots[].
This commit is contained in:
slhale 2015-08-04 13:10:29 -07:00
parent 15e39e00c2
commit eab140df48
2 changed files with 12 additions and 10 deletions

View File

@ -2,6 +2,13 @@
"name": "Search", "name": "Search",
"description": "Allows the user to search through the file tree.", "description": "Allows the user to search through the file tree.",
"extensions": { "extensions": {
"constants": [
{
"key": "GENERIC_SEARCH_ROOTS",
"value": [ "ROOT" ],
"priority": "fallback"
}
],
"controllers": [ "controllers": [
{ {
"key": "SearchController", "key": "SearchController",
@ -32,7 +39,7 @@
"provides": "searchService", "provides": "searchService",
"type": "provider", "type": "provider",
"implementation": "services/GenericSearchProvider.js", "implementation": "services/GenericSearchProvider.js",
"depends": [ "$q", "objectService", "workerService", "roots[]" ] "depends": [ "$q", "objectService", "workerService", "GENERIC_SEARCH_ROOTS" ]
}, },
{ {
"provides": "searchService", "provides": "searchService",

View File

@ -43,9 +43,10 @@ define(
* domain objects can be gotten. * domain objects can be gotten.
* @param {WorkerService} workerService The service which allows * @param {WorkerService} workerService The service which allows
* more easy creation of web workers. * more easy creation of web workers.
* @param {roots[]} roots An array of all the root domain objects. * @param {GENERIC_SEARCH_ROOTS} ROOTS An array of the root
* domain objects' IDs.
*/ */
function GenericSearchProvider($q, objectService, workerService, roots) { function GenericSearchProvider($q, objectService, workerService, ROOTS) {
var worker = workerService.run('genericSearchWorker'), var worker = workerService.run('genericSearchWorker'),
pendingQueries = {}; pendingQueries = {};
// pendingQueries is a dictionary with the key value pairs st // pendingQueries is a dictionary with the key value pairs st
@ -142,14 +143,8 @@ define(
// Converts the filetree into a list // Converts the filetree into a list
function getItems(timeout) { function getItems(timeout) {
var rootIds = [],
i;
for (i = 0; i < roots.length; i += 1) {
rootIds.push(roots[i].id);
}
// Aquire root objects // Aquire root objects
objectService.getObjects(rootIds).then(function (objectsById) { objectService.getObjects(ROOTS).then(function (objectsById) {
var objects = [], var objects = [],
id; id;