diff --git a/src/plugins/timeConductor/ConductorComponent.vue b/src/plugins/timeConductor/ConductorComponent.vue index 30ffe11a55..c4b08df3e9 100644 --- a/src/plugins/timeConductor/ConductorComponent.vue +++ b/src/plugins/timeConductor/ConductorComponent.vue @@ -100,14 +100,14 @@ export default { inject: ['openmct', 'configuration'], setup(props) { const openmct = inject('openmct'); - const { timeContext } = useTimeContext(openmct, () => props.objectPath); + const { timeContext } = useTimeContext(openmct); const { timeSystemFormatter, timeSystemDurationFormatter, isTimeSystemUTCBased } = - useTimeSystem(openmct); + useTimeSystem(openmct, timeContext); const { timeMode, isFixedTimeMode, isRealTimeMode, getAllModeMetadata, getModeMetadata } = - useTimeMode(openmct); - const { bounds, isTick } = useTimeBounds(openmct); - const { clock, getAllClockMetadata, getClockMetadata } = useClock(openmct); - const { offsets } = useClockOffsets(openmct); + useTimeMode(openmct, timeContext); + const { bounds, isTick } = useTimeBounds(openmct, timeContext); + const { clock, getAllClockMetadata, getClockMetadata } = useClock(openmct, timeContext); + const { offsets } = useClockOffsets(openmct, timeContext); provide('timeSystemFormatter', timeSystemFormatter); provide('timeSystemDurationFormatter', timeSystemDurationFormatter); diff --git a/src/plugins/timeConductor/independent/IndependentTimeConductor.vue b/src/plugins/timeConductor/independent/IndependentTimeConductor.vue index a6e1c416f7..e5af12e563 100644 --- a/src/plugins/timeConductor/independent/IndependentTimeConductor.vue +++ b/src/plugins/timeConductor/independent/IndependentTimeConductor.vue @@ -111,15 +111,15 @@ export default { }, setup(props) { const openmct = inject('openmct'); - const { timeContext } = useTimeContext(openmct, getReactiveObjectPath); + const { timeContext } = useTimeContext(openmct, () => props.objectPath); const { timeSystemFormatter, timeSystemDurationFormatter, isTimeSystemUTCBased } = - useTimeSystem(openmct, getReactiveObjectPath); + useTimeSystem(openmct, timeContext); const { timeMode, isFixedTimeMode, isRealTimeMode, getAllModeMetadata, getModeMetadata } = - useTimeMode(openmct, getReactiveObjectPath); - const { bounds, isTick } = useTimeBounds(openmct, getReactiveObjectPath); - const { clock, getAllClockMetadata, getClockMetadata } = useClock(openmct, getReactiveObjectPath); - const { offsets } = useClockOffsets(openmct, getReactiveObjectPath); + useTimeMode(openmct, timeContext); + const { bounds, isTick } = useTimeBounds(openmct, timeContext); + const { clock, getAllClockMetadata, getClockMetadata } = useClock(openmct, timeContext); + const { offsets } = useClockOffsets(openmct, timeContext); watch(timeContext, () => { console.log('context changed setup'); @@ -225,16 +225,22 @@ export default { this.handleIndependentTimeConductorChange(); }, clock() { - this.saveClock(); + if (this.independentTCEnabled) { + this.saveClock(); + } }, timeMode() { - this.saveMode(); + if (this.independentTCEnabled) { + this.saveMode(); + } }, clockOffsets() { - this.saveClockOffsets(); + if (this.independentTCEnabled) { + this.saveClockOffsets(); + } }, bounds() { - if (this.isTick === false) { + if (this.independentTCEnabled && this.isTick === false) { this.saveFixedBounds(); } } @@ -321,12 +327,20 @@ export default { const independentTimeContextBoundsOrOffsets = this.isFixedTimeMode ? bounds : offsets; const independentTimeContextClockKey = this.isFixedTimeMode ? undefined : clockKey; - if (!this.timeContext.hasOwnContext()) { + const independentTimeContext = this.openmct.time.getIndependentContext(this.keyString); + + if (!independentTimeContext.hasOwnContext()) { this.unregisterIndependentTimeContext = this.openmct.time.addIndependentContext( this.keyString, independentTimeContextBoundsOrOffsets, independentTimeContextClockKey ); + } else { + if (this.isRealTimeMode) { + independentTimeContext.setClock(this.timeOptions.clock); + } + + independentTimeContext.setMode(this.timeOptions.mode, independentTimeContextBoundsOrOffsets); } }, registerIndependentTimeOffsets() { diff --git a/src/plugins/timeConductor/useClock.js b/src/plugins/timeConductor/useClock.js index a43ef0e983..247d28507a 100644 --- a/src/plugins/timeConductor/useClock.js +++ b/src/plugins/timeConductor/useClock.js @@ -23,7 +23,6 @@ import { onBeforeUnmount, shallowRef, watch } from 'vue'; import { TIME_CONTEXT_EVENTS } from '../../api/time/constants.js'; -import { useTimeContext } from './useTimeContext.js'; /** * Provides reactive `clock` which is reactive to a time context, @@ -38,11 +37,9 @@ import { useTimeContext } from './useTimeContext.js'; * getClockMetadata: () => Object * }} */ -export function useClock(openmct, objectPath) { +export function useClock(openmct, timeContext) { let stopObservingClock; - const { timeContext } = useTimeContext(openmct, objectPath); - const clock = shallowRef(timeContext.value.getClock()); onBeforeUnmount(() => stopObservingClock?.()); diff --git a/src/plugins/timeConductor/useClockOffsets.js b/src/plugins/timeConductor/useClockOffsets.js index 2fb423dbf6..9fca3b2cd0 100644 --- a/src/plugins/timeConductor/useClockOffsets.js +++ b/src/plugins/timeConductor/useClockOffsets.js @@ -23,7 +23,6 @@ import { onBeforeUnmount, shallowRef, watch } from 'vue'; import { TIME_CONTEXT_EVENTS } from '../../api/time/constants.js'; -import { useTimeContext } from './useTimeContext.js'; /** * Provides reactive `offsets`, @@ -37,11 +36,9 @@ import { useTimeContext } from './useTimeContext.js'; * offsets: import('vue').Ref, * }} */ -export function useClockOffsets(openmct, objectPath) { +export function useClockOffsets(openmct, timeContext) { let stopObservingClockOffsets; - const { timeContext } = useTimeContext(openmct, objectPath); - const offsets = shallowRef(timeContext.value.getClockOffsets()); onBeforeUnmount(() => stopObservingClockOffsets?.()); diff --git a/src/plugins/timeConductor/useTimeBounds.js b/src/plugins/timeConductor/useTimeBounds.js index 54266d4635..e5239a876e 100644 --- a/src/plugins/timeConductor/useTimeBounds.js +++ b/src/plugins/timeConductor/useTimeBounds.js @@ -23,7 +23,6 @@ import { onBeforeUnmount, ref, shallowRef, watch } from 'vue'; import { TIME_CONTEXT_EVENTS } from '../../api/time/constants.js'; -import { useTimeContext } from './useTimeContext.js'; import throttle from '../../utils/throttle.js'; const THROTTLE_RATE = 300; @@ -40,11 +39,9 @@ const THROTTLE_RATE = 300; * isTick: import('vue').Ref * }} */ -export function useTimeBounds(openmct, objectPath) { +export function useTimeBounds(openmct, timeContext) { let stopObservingTimeBounds; - const { timeContext } = useTimeContext(openmct, objectPath); - const bounds = shallowRef(timeContext.value.getBounds()); const isTick = ref(false); diff --git a/src/plugins/timeConductor/useTimeMode.js b/src/plugins/timeConductor/useTimeMode.js index 05d8dbfeba..02d8587a6e 100644 --- a/src/plugins/timeConductor/useTimeMode.js +++ b/src/plugins/timeConductor/useTimeMode.js @@ -27,7 +27,6 @@ import { REALTIME_MODE_KEY, TIME_CONTEXT_EVENTS } from '../../api/time/constants.js'; -import { useTimeContext } from './useTimeContext.js'; /** * Provides reactive `timeMode` which is reactive to a time context, @@ -42,11 +41,9 @@ import { useTimeContext } from './useTimeContext.js'; * isRealTimeMode: import('vue').Ref * }} */ -export function useTimeMode(openmct, objectPath) { +export function useTimeMode(openmct, timeContext) { let stopObservingTimeMode; - const { timeContext } = useTimeContext(openmct, objectPath); - const timeMode = ref(timeContext.value.getMode()); const isFixedTimeMode = computed(() => timeMode.value === FIXED_MODE_KEY); const isRealTimeMode = computed(() => timeMode.value === REALTIME_MODE_KEY); diff --git a/src/plugins/timeConductor/useTimeSystem.js b/src/plugins/timeConductor/useTimeSystem.js index 99b6386c23..c381b03696 100644 --- a/src/plugins/timeConductor/useTimeSystem.js +++ b/src/plugins/timeConductor/useTimeSystem.js @@ -23,7 +23,6 @@ import { onBeforeUnmount, ref, watch } from 'vue'; import { TIME_CONTEXT_EVENTS } from '../../api/time/constants.js'; -import { useTimeContext } from './useTimeContext.js'; const DEFAULT_DURATION_FORMATTER = 'duration'; @@ -43,11 +42,9 @@ const DEFAULT_DURATION_FORMATTER = 'duration'; * isTimeSystemUTCBased: import('vue').Ref * }} */ -export function useTimeSystem(openmct, objectPath) { +export function useTimeSystem(openmct, timeContext) { let stopObservingTimeSystem; - const { timeContext } = useTimeContext(openmct, objectPath); - const initialTimeSystem = timeContext.value.getTimeSystem(); const timeSystemKey = ref(initialTimeSystem.key);