@@ -104,7 +104,7 @@ export default {
104
104
});
105
105
};
106
106
},
107
- getPathsForObjects(objectsNeedingPaths) {
107
+ getPathsForObjects(objectsNeedingPaths, abortSignal ) {
108
108
return Promise.all(
109
109
objectsNeedingPaths.map(async (domainObject) => {
110
110
if (!domainObject) {
@@ -114,7 +114,9 @@ export default {
114
114
115
115
const keyStringForObject = this.openmct.objects.makeKeyString(domainObject.identifier);
116
116
const originalPathObjects = await this.openmct.objects.getOriginalPath(
117
- keyStringForObject
117
+ keyStringForObject,
118
+ [],
119
+ abortSignal
118
120
);
119
121
120
122
return {
@@ -130,45 +132,56 @@ export default {
130
132
this.searchLoading = true;
131
133
this.$refs.searchResultsDropDown.showSearchStarted();
132
134
this.abortSearchController = new AbortController();
133
- const abortSignal = this.abortSearchController.signal;
135
+
134
136
try {
135
- this.annotationSearchResults = await this.openmct.annotation.searchForTags(
136
- this.searchValue,
137
- abortSignal
138
- );
139
- const fullObjectSearchResults = await Promise.all(
140
- this.openmct.objects.search(this.searchValue, abortSignal)
141
- );
142
- const aggregatedObjectSearchResults = fullObjectSearchResults.flat();
143
- const aggregatedObjectSearchResultsWithPaths = await this.getPathsForObjects(
144
- aggregatedObjectSearchResults
145
- );
146
- const filterAnnotationsAndValidPaths = aggregatedObjectSearchResultsWithPaths.filter(
147
- (result) => {
148
- if (this.openmct.annotation.isAnnotation(result)) {
149
- return false;
150
- }
137
+ const searchObjectsPromise = this.searchObjects(this.abortSearchController.signal);
138
+ const searchAnnotationsPromise = this.searchAnnotations(this.abortSearchController.signal);
139
+
140
+ // Wait for all promises, but they process their results as they complete
141
+ await Promise.allSettled([searchObjectsPromise, searchAnnotationsPromise]);
151
142
152
- return this.openmct.objects.isReachable(result?.objectPath);
153
- }
154
- );
155
- this.objectSearchResults = filterAnnotationsAndValidPaths;
156
143
this.searchLoading = false;
157
144
this.showSearchResults();
158
145
} catch (error) {
159
146
this.searchLoading = false;
160
147
161
- if (this.abortSearchController) {
162
- delete this.abortSearchController;
163
- }
164
-
165
148
// Is this coming from the AbortController?
166
149
// If so, we can swallow the error. If not, 🤮 it to console
167
150
if (error.name !== 'AbortError') {
168
151
console.error(`😞 Error searching`, error);
169
152
}
153
+ } finally {
154
+ if (this.abortSearchController) {
155
+ delete this.abortSearchController;
156
+ }
157
+ }
158
+ },
159
+ async searchObjects(abortSignal) {
160
+ const objectSearchPromises = this.openmct.objects.search(this.searchValue, abortSignal);
161
+ for await (const objectSearchResult of objectSearchPromises) {
162
+ const objectsWithPaths = await this.getPathsForObjects(objectSearchResult, abortSignal);
163
+ this.objectSearchResults.push(
164
+ ...objectsWithPaths.filter((result) => {
165
+ // Check if the result is NOT an annotation and has a reachable path
166
+ return (
167
+ !this.openmct.annotation.isAnnotation(result) &&
168
+ this.openmct.objects.isReachable(result?.objectPath)
169
+ );
170
+ })
171
+ );
172
+ // Display the available results so far for objects
173
+ this.showSearchResults();
170
174
}
171
175
},
176
+ async searchAnnotations(abortSignal) {
177
+ const annotationSearchResults = await this.openmct.annotation.searchForTags(
178
+ this.searchValue,
179
+ abortSignal
180
+ );
181
+ this.annotationSearchResults = annotationSearchResults;
182
+ // Display the available results so far for annotations
183
+ this.showSearchResults();
184
+ },
172
185
showSearchResults() {
173
186
const dropdownOptions = {
174
187
searchLoading: this.searchLoading,
0 commit comments