From cf1c08dd56fb4d3973668fb52c456b439ef80b33 Mon Sep 17 00:00:00 2001 From: Chris Jordan Date: Wed, 15 May 2024 16:28:34 -0400 Subject: [PATCH] hacky timestamp synchronization --- src/layer/annotation/index.ts | 32 ++++++++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/src/layer/annotation/index.ts b/src/layer/annotation/index.ts index 35c1a4e430..94c31f9aa6 100644 --- a/src/layer/annotation/index.ts +++ b/src/layer/annotation/index.ts @@ -28,6 +28,8 @@ import { } from "#src/annotation/index.js"; import type { CoordinateTransformSpecification } from "#src/coordinate_transform.js"; import { makeCoordinateSpace } from "#src/coordinate_transform.js"; +import { CaveAnnotationSource } from "#src/datasource/cave/frontend.js"; +import { GraphConnection } from "#src/datasource/graphene/frontend.js"; import type { DataSourceSpecification } from "#src/datasource/index.js"; import { localAnnotationsUrl, LocalDataSource } from "#src/datasource/index.js"; import type { LayerManager, ManagedUserLayer } from "#src/layer/index.js"; @@ -404,8 +406,34 @@ export class AnnotationUserLayer extends Base { constructor(managedLayer: Borrowed) { super(managedLayer); - this.linkedSegmentationLayers.changed.add( - this.specificationChanged.dispatch, + this.registerDisposer( + this.linkedSegmentationLayers.changed.add(() => { + console.log("linkedSegmentationLayers.changed"); + for (const { source } of this.annotationStates.value) { + if (source instanceof CaveAnnotationSource) { + const { timestamp } = source.parameters; + for (const relationship of this.linkedSegmentationLayers + .annotationStates.relationships) { + const linkedLayer = + this.linkedSegmentationLayers.get(relationship); + if (linkedLayer) { + const layer = linkedLayer.layerRef.layer?.layer; + if (layer) { + if (layer instanceof SegmentationUserLayer) { + const graphConnection = layer.graphConnection.value; + if (graphConnection instanceof GraphConnection) { + graphConnection.state.timestamp.value = new Date( + timestamp, + ).valueOf(); + } + } + } + } + } + } + } + this.specificationChanged.dispatch(); + }), ); this.annotationDisplayState.ignoreNullSegmentFilter.changed.add( this.specificationChanged.dispatch,