From f789775b1c90dcf24da4b7faa5e268b61f34b903 Mon Sep 17 00:00:00 2001 From: Deep Tailor Date: Tue, 23 Feb 2021 16:51:50 -0800 Subject: [PATCH] Fixes isMutable error when domainobject is undefined (#3690) * fix isMutable error when domainobject is undefined Co-authored-by: Deep Tailor Co-authored-by: Shefali Joshi Co-authored-by: Andrew Henry --- .../displayLayout/components/SubobjectView.vue | 12 +++++++++--- .../displayLayout/components/TelemetryView.vue | 12 +++++++++--- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/src/plugins/displayLayout/components/SubobjectView.vue b/src/plugins/displayLayout/components/SubobjectView.vue index a3f6ab5680..eb6bceb5b9 100644 --- a/src/plugins/displayLayout/components/SubobjectView.vue +++ b/src/plugins/displayLayout/components/SubobjectView.vue @@ -109,7 +109,8 @@ export default { data() { return { domainObject: undefined, - currentObjectPath: [] + currentObjectPath: [], + mutablePromise: undefined }; }, watch: { @@ -130,7 +131,7 @@ export default { }, mounted() { if (this.openmct.objects.supportsMutation(this.item.identifier)) { - this.openmct.objects.getMutable(this.item.identifier) + this.mutablePromise = this.openmct.objects.getMutable(this.item.identifier) .then(this.setObject); } else { this.openmct.objects.get(this.item.identifier) @@ -142,13 +143,18 @@ export default { this.removeSelectable(); } - if (this.domainObject.isMutable) { + if (this.mutablePromise) { + this.mutablePromise.then(() => { + this.openmct.objects.destroyMutable(this.domainObject); + }); + } else { this.openmct.objects.destroyMutable(this.domainObject); } }, methods: { setObject(domainObject) { this.domainObject = domainObject; + this.mutablePromise = undefined; this.currentObjectPath = [this.domainObject].concat(this.objectPath.slice()); this.$nextTick(() => { let reference = this.$refs.objectFrame; diff --git a/src/plugins/displayLayout/components/TelemetryView.vue b/src/plugins/displayLayout/components/TelemetryView.vue index ffc86ba5f0..18408a4e0e 100644 --- a/src/plugins/displayLayout/components/TelemetryView.vue +++ b/src/plugins/displayLayout/components/TelemetryView.vue @@ -131,7 +131,8 @@ export default { domainObject: undefined, formats: undefined, viewKey: `alphanumeric-format-${Math.random()}`, - status: '' + status: '', + mutablePromise: undefined }; }, computed: { @@ -213,7 +214,7 @@ export default { }, mounted() { if (this.openmct.objects.supportsMutation(this.item.identifier)) { - this.openmct.objects.getMutable(this.item.identifier) + this.mutablePromise = this.openmct.objects.getMutable(this.item.identifier) .then(this.setObject); } else { this.openmct.objects.get(this.item.identifier) @@ -235,7 +236,11 @@ export default { this.openmct.time.off("bounds", this.refreshData); - if (this.domainObject.isMutable) { + if (this.mutablePromise) { + this.mutablePromise.then(() => { + this.openmct.objects.destroyMutable(this.domainObject); + }); + } else { this.openmct.objects.destroyMutable(this.domainObject); } }, @@ -296,6 +301,7 @@ export default { }, setObject(domainObject) { this.domainObject = domainObject; + this.mutablePromise = undefined; this.keyString = this.openmct.objects.makeKeyString(domainObject.identifier); this.metadata = this.openmct.telemetry.getMetadata(this.domainObject); this.limitEvaluator = this.openmct.telemetry.limitEvaluator(this.domainObject);