fix(#5646): abort pending annotations requests on nav away from notebooks or plots

This commit is contained in:
Mazzella, Jesse D. (ARC-TI)[KBR Wyle Services, LLC] 2023-05-31 13:04:59 -07:00
parent f4007d3dfc
commit c7542d0052
2 changed files with 18 additions and 7 deletions

View File

@ -306,14 +306,17 @@ export default {
this.getSearchResults = debounce(this.getSearchResults, 500);
this.syncUrlWithPageAndSection = debounce(this.syncUrlWithPageAndSection, 100);
},
async mounted() {
async created() {
this.transaction = null;
this.abortController = new AbortController();
await this.loadAnnotations();
},
async mounted() {
this.formatSidebar();
this.setSectionAndPageFromUrl();
this.openmct.selection.on('change', this.updateSelection);
this.transaction = null;
window.addEventListener('orientationchange', this.formatSidebar);
window.addEventListener('hashchange', this.setSectionAndPageFromUrl);
this.filterAndSortEntries();
@ -321,9 +324,10 @@ export default {
this.domainObject,
'*',
this.filterAndSortEntries
);
},
);
},
beforeDestroy() {
this.abortController.abort();
if (this.unlisten) {
this.unlisten();
}
@ -387,8 +391,10 @@ export default {
this.lastLocalAnnotationCreation = this.domainObject.annotationLastCreated ?? 0;
const foundAnnotations = await this.openmct.annotation.getAnnotations(
this.domainObject.identifier
this.domainObject.identifier,
this.abortController.signal
);
foundAnnotations.forEach((foundAnnotation) => {
const targetId = Object.keys(foundAnnotation.targets)[0];
const entryId = foundAnnotation.targets[targetId].entryId;

View File

@ -331,6 +331,9 @@ export default {
return this.pending === 0 && this.loaded;
}
},
created() {
this.abortController = new AbortController();
},
watch: {
initGridLines(newGridLines) {
this.gridLines = newGridLines;
@ -398,6 +401,7 @@ export default {
this.loaded = true;
},
beforeDestroy() {
this.abortController.abort();
this.openmct.selection.off('change', this.updateSelection);
document.removeEventListener('keydown', this.handleKeyDown);
document.removeEventListener('keyup', this.handleKeyUp);
@ -621,7 +625,8 @@ export default {
await Promise.all(
this.seriesModels.map(async (seriesModel) => {
const seriesAnnotations = await this.openmct.annotation.getAnnotations(
seriesModel.model.identifier
seriesModel.model.identifier,
this.abortController.signal
);
rawAnnotationsForPlot.push(...seriesAnnotations);
})