@@ -37,6 +37,16 @@ export default ({
3737
3838 const isClassification = ! Boolean ( iface . multipleRegionLabels )
3939
40+ const saveCurrentIndexAnnotation = useEventCallback ( ( output ) => {
41+ const img = output . images [ selectedIndex ]
42+ onSaveTaskOutputItem (
43+ selectedIndex ,
44+ multipleRegions
45+ ? ( img . regions || [ ] ) . map ( convertFromRIARegionFmt )
46+ : convertToRIAImageFmt ( ( img . regions || [ ] ) [ 0 ] )
47+ )
48+ } )
49+
4050 const labelProps = useMemo (
4151 ( ) =>
4252 isClassification
@@ -57,17 +67,7 @@ export default ({
5767 iface . multipleRegions || iface . multipleRegions === undefined
5868
5969 const onExit = useEventCallback ( ( output , nextAction ) => {
60- const regionMat = ( output . images || [ ] ) . map ( ( img ) =>
61- ( img . regions || [ ] ) . map ( convertFromRIARegionFmt )
62- )
63-
64- for ( let i = 0 ; i < regionMat . length ; i ++ ) {
65- if ( multipleRegions ) {
66- onSaveTaskOutputItem ( i , regionMat [ i ] )
67- } else {
68- onSaveTaskOutputItem ( i , regionMat [ i ] [ 0 ] )
69- }
70- }
70+ saveCurrentIndexAnnotation ( output )
7171 changeShowTags ( output . showTags )
7272 changeSelectedTool ( output . selectedTool )
7373 if ( containerProps . onExit ) containerProps . onExit ( nextAction )
@@ -76,25 +76,15 @@ export default ({
7676 if ( selectedIndex + 1 > samples . length ) {
7777 onExit ( output , "go-to-next" )
7878 } else {
79- onSaveTaskOutputItem (
80- selectedIndex ,
81- multipleRegions
82- ? output . regions . map ( convertFromRIARegionFmt )
83- : convertToRIAImageFmt ( output . regions [ 0 ] )
84- )
79+ saveCurrentIndexAnnotation ( output )
8580 changeSelectedIndex ( selectedIndex + 1 )
8681 }
8782 } )
8883 const onPrevImage = useEventCallback ( ( output ) => {
8984 if ( selectedIndex - 1 < 0 ) {
9085 onExit ( output , "go-to-previous" )
9186 } else {
92- onSaveTaskOutputItem (
93- selectedIndex ,
94- multipleRegions
95- ? output . regions . map ( convertFromRIARegionFmt )
96- : convertToRIAImageFmt ( output . regions [ 0 ] )
97- )
87+ saveCurrentIndexAnnotation ( output )
9888 changeSelectedIndex ( selectedIndex - 1 )
9989 }
10090 } )
0 commit comments