mirror of
https://github.com/nasa/openmct.git
synced 2025-06-19 23:53:49 +00:00
[ObjectAPI] Cleanup code and remove possible memory leak (#6269)
* Destroy mutable after refresh * Check if domainObject supports mutation before getting mutable
This commit is contained in:
@ -225,24 +225,21 @@ export default class ObjectAPI {
|
|||||||
throw new Error('Provider does not support get!');
|
throw new Error('Provider does not support get!');
|
||||||
}
|
}
|
||||||
|
|
||||||
let objectPromise = provider.get(identifier, abortSignal).then(result => {
|
let objectPromise = provider.get(identifier, abortSignal).then(domainObject => {
|
||||||
delete this.cache[keystring];
|
delete this.cache[keystring];
|
||||||
|
domainObject = this.applyGetInterceptors(identifier, domainObject);
|
||||||
|
|
||||||
result = this.applyGetInterceptors(identifier, result);
|
if (this.supportsMutation(identifier)) {
|
||||||
if (result.isMutable) {
|
const mutableDomainObject = this.toMutable(domainObject);
|
||||||
result.$refresh(result);
|
mutableDomainObject.$refresh(domainObject);
|
||||||
} else {
|
this.destroyMutable(mutableDomainObject);
|
||||||
let mutableDomainObject = this.toMutable(result);
|
|
||||||
mutableDomainObject.$refresh(result);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return domainObject;
|
||||||
}).catch((result) => {
|
}).catch((error) => {
|
||||||
console.warn(`Failed to retrieve ${keystring}:`, result);
|
console.warn(`Failed to retrieve ${keystring}:`, error);
|
||||||
|
|
||||||
delete this.cache[keystring];
|
delete this.cache[keystring];
|
||||||
|
const result = this.applyGetInterceptors(identifier);
|
||||||
result = this.applyGetInterceptors(identifier);
|
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
});
|
});
|
||||||
|
Reference in New Issue
Block a user