mirror of
https://github.com/nasa/openmct.git
synced 2025-06-23 17:53:28 +00:00
[Search] Break up item indexing
Use timeouts to make the generic search's item indexing not block up the page.
This commit is contained in:
@ -14,7 +14,7 @@
|
||||
"provides": "searchService",
|
||||
"type": "provider",
|
||||
"implementation": "GenericSearchProvider.js",
|
||||
"depends": [ "$q", "objectService", "workerService", "GENERIC_SEARCH_ROOTS" ]
|
||||
"depends": [ "$q", "$timeout", "objectService", "workerService", "GENERIC_SEARCH_ROOTS" ]
|
||||
},
|
||||
{
|
||||
"provides": "searchService",
|
||||
|
@ -39,6 +39,7 @@ define(
|
||||
*
|
||||
* @constructor
|
||||
* @param $q Angular's $q, for promise consolidation.
|
||||
* @param $timeout Angular's $timeout, for delayed funtion execution.
|
||||
* @param {ObjectService} objectService The service from which
|
||||
* domain objects can be gotten.
|
||||
* @param {WorkerService} workerService The service which allows
|
||||
@ -46,7 +47,7 @@ define(
|
||||
* @param {GENERIC_SEARCH_ROOTS[]} ROOTS An array of the root
|
||||
* domain objects.
|
||||
*/
|
||||
function GenericSearchProvider($q, objectService, workerService, ROOTS) {
|
||||
function GenericSearchProvider($q, $timeout, objectService, workerService, ROOTS) {
|
||||
var worker = workerService.run('genericSearchWorker'),
|
||||
indexed = {},
|
||||
pendingQueries = {};
|
||||
@ -134,14 +135,21 @@ define(
|
||||
|
||||
if (node.hasCapability && node.hasCapability('composition')) {
|
||||
// This node has children
|
||||
node.getCapability('composition').invoke().then(function (children) {
|
||||
// Index the children
|
||||
if (children.constructor === Array) {
|
||||
indexItems(children);
|
||||
} else {
|
||||
indexItems([children]);
|
||||
}
|
||||
});
|
||||
|
||||
// Make sure that this is async, so doesn't block up page
|
||||
$timeout(function () {
|
||||
// Get the children...
|
||||
node.useCapability('composition').then(function (children) {
|
||||
$timeout(function () {
|
||||
// ... then index the children
|
||||
if (children.constructor === Array) {
|
||||
indexItems(children);
|
||||
} else {
|
||||
indexItems([children]);
|
||||
}
|
||||
}, 100);
|
||||
});
|
||||
}, 100);
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user