mirror of
https://github.com/nasa/openmct.git
synced 2024-12-22 06:27:48 +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() {
|
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;
|
let timeContext = this.globalTimeContext;
|
||||||
this.objectPath.some((item, index) => {
|
this.objectPath.some((item, index) => {
|
||||||
const key = this.openmct.objects.makeKeyString(item.identifier);
|
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);
|
const itemContext = this.globalTimeContext.independentContexts.get(key);
|
||||||
if (index > 0 && itemContext && itemContext.hasOwnContext()) {
|
if (index > 0 && itemContext && itemContext.hasOwnContext()) {
|
||||||
//upstream time context
|
//upstream time context
|
||||||
|
@ -93,18 +93,43 @@ describe("The Independent Time API", function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("follows a parent time context given the objectPath", () => {
|
it("follows a parent time context given the objectPath", () => {
|
||||||
let timeContext = api.getContextForView([{
|
api.getContextForView([{
|
||||||
identifier: {
|
identifier: {
|
||||||
namespace: '',
|
namespace: '',
|
||||||
key: 'blah'
|
key: 'blah'
|
||||||
}
|
}
|
||||||
}, {
|
}]);
|
||||||
|
let destroyTimeContext = api.addIndependentContext('blah', independentBounds);
|
||||||
|
let timeContext = api.getContextForView([{
|
||||||
identifier: {
|
identifier: {
|
||||||
namespace: '',
|
namespace: '',
|
||||||
key: domainObjectKey
|
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);
|
expect(timeContext.bounds()).toEqual(independentBounds);
|
||||||
destroyTimeContext();
|
destroyTimeContext();
|
||||||
expect(timeContext.bounds()).toEqual(bounds);
|
expect(timeContext.bounds()).toEqual(bounds);
|
||||||
|
@ -227,6 +227,10 @@ export default {
|
|||||||
if (this.isFixed) {
|
if (this.isFixed) {
|
||||||
offsets = this.timeOptions.fixedOffsets;
|
offsets = this.timeOptions.fixedOffsets;
|
||||||
} else {
|
} else {
|
||||||
|
if (this.timeOptions.clockOffsets === undefined) {
|
||||||
|
this.timeOptions.clockOffsets = this.openmct.time.clockOffsets();
|
||||||
|
}
|
||||||
|
|
||||||
offsets = this.timeOptions.clockOffsets;
|
offsets = this.timeOptions.clockOffsets;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user