mirror of
https://github.com/nasa/openmct.git
synced 2024-12-21 14:07:50 +00:00
[TimeAPI] Fix independent time context check (#6308)
* Fix independent time context to check first object in path (self) for upstream content instead of last object in path * Revert changes that don't allow unregistering independent time context --------- Co-authored-by: Shefali <simplyrender@gmail.com>
This commit is contained in:
parent
302dbe7359
commit
7dcccee1ae
@ -202,16 +202,10 @@ class IndependentTimeContext extends TimeContext {
|
||||
}
|
||||
|
||||
getUpstreamContext() {
|
||||
const objectKey = this.openmct.objects.makeKeyString(this.objectPath[this.objectPath.length - 1].identifier);
|
||||
const doesObjectHaveTimeContext = this.globalTimeContext.independentContexts.get(objectKey);
|
||||
if (doesObjectHaveTimeContext) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
let timeContext = this.globalTimeContext;
|
||||
this.objectPath.some((item, index) => {
|
||||
const key = this.openmct.objects.makeKeyString(item.identifier);
|
||||
//last index is the view object itself
|
||||
//first index is the view object itself
|
||||
const itemContext = this.globalTimeContext.independentContexts.get(key);
|
||||
if (index > 0 && itemContext && itemContext.hasOwnContext()) {
|
||||
//upstream time context
|
||||
|
@ -93,18 +93,43 @@ describe("The Independent Time API", function () {
|
||||
});
|
||||
|
||||
it("follows a parent time context given the objectPath", () => {
|
||||
let timeContext = api.getContextForView([{
|
||||
api.getContextForView([{
|
||||
identifier: {
|
||||
namespace: '',
|
||||
key: 'blah'
|
||||
}
|
||||
}, {
|
||||
}]);
|
||||
let destroyTimeContext = api.addIndependentContext('blah', independentBounds);
|
||||
let timeContext = api.getContextForView([{
|
||||
identifier: {
|
||||
namespace: '',
|
||||
key: domainObjectKey
|
||||
}
|
||||
}, {
|
||||
identifier: {
|
||||
namespace: '',
|
||||
key: 'blah'
|
||||
}
|
||||
}]);
|
||||
let destroyTimeContext = api.addIndependentContext('blah', independentBounds);
|
||||
expect(timeContext.bounds()).toEqual(independentBounds);
|
||||
destroyTimeContext();
|
||||
expect(timeContext.bounds()).toEqual(bounds);
|
||||
});
|
||||
|
||||
it("uses an object's independent time context if the parent doesn't have one", () => {
|
||||
let timeContext = api.getContextForView([{
|
||||
identifier: {
|
||||
namespace: '',
|
||||
key: domainObjectKey
|
||||
}
|
||||
}, {
|
||||
identifier: {
|
||||
namespace: '',
|
||||
key: 'blah'
|
||||
}
|
||||
}]);
|
||||
expect(timeContext.bounds()).toEqual(bounds);
|
||||
let destroyTimeContext = api.addIndependentContext(domainObjectKey, independentBounds);
|
||||
expect(timeContext.bounds()).toEqual(independentBounds);
|
||||
destroyTimeContext();
|
||||
expect(timeContext.bounds()).toEqual(bounds);
|
||||
|
@ -227,6 +227,10 @@ export default {
|
||||
if (this.isFixed) {
|
||||
offsets = this.timeOptions.fixedOffsets;
|
||||
} else {
|
||||
if (this.timeOptions.clockOffsets === undefined) {
|
||||
this.timeOptions.clockOffsets = this.openmct.time.clockOffsets();
|
||||
}
|
||||
|
||||
offsets = this.timeOptions.clockOffsets;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user