1- import { computed , ref , unref } from 'vue' ;
2- import { until } from '@vueuse/core' ;
1+ import { ref } from 'vue' ;
32import vtkImageData from '@kitware/vtk.js/Common/DataModel/ImageData' ;
43import vtkBoundingBox from '@kitware/vtk.js/Common/DataModel/BoundingBox' ;
54import { defineStore } from 'pinia' ;
@@ -8,7 +7,7 @@ import { Maybe } from '@/src/types';
87import { ensureSameSpace } from '@/src/io/resample/resample' ;
98import { useErrorMessage } from '../composables/useErrorMessage' ;
109import { Manifest , StateFile } from '../io/state-file/schema' ;
11- import useChunkStore from './chunks ' ;
10+ import { untilLoaded } from '../composables/untilLoaded ' ;
1211
1312// differ from Image/Volume IDs with a branded type
1413export type LayerID = string & { __type : 'LayerID' } ;
@@ -39,6 +38,9 @@ export const useLayersStore = defineStore('layer', () => {
3938 { selection : source , id } as Layer ,
4039 ] ;
4140
41+ // ensureSameSpace need final image array to resample, so wait for all chunks
42+ await untilLoaded ( source ) ;
43+
4244 const [ parentImage , sourceImage ] = await Promise . all (
4345 [ parent , source ] . map ( getImage )
4446 ) ;
@@ -68,12 +70,6 @@ export const useLayersStore = defineStore('layer', () => {
6870 parent : DataSelection ,
6971 source : DataSelection
7072 ) {
71- // ensureSameSpace need final image array to resample, so wait for all chunks
72- const doneLoading = computed (
73- ( ) => ! unref ( useChunkStore ( ) . chunkImageById [ source ] . isLoading )
74- ) ;
75- await until ( doneLoading ) . toBe ( true ) ;
76-
7773 return useErrorMessage ( 'Failed to build layer' , async ( ) => {
7874 try {
7975 await this . _addLayer ( parent , source ) ;
0 commit comments