@@ -17,7 +17,7 @@ import { Hotkey } from '../core/Hotkey';
1717import ToolsManager from '../tools/Manager' ;
1818import Utils from '../utils' ;
1919import { guidGenerator } from '../utils/unique' ;
20- import { delay , isDefined } from '../utils/utilities' ;
20+ import { clamp , delay , isDefined } from '../utils/utilities' ;
2121import AnnotationStore from './Annotation/store' ;
2222import Project from './ProjectStore' ;
2323import Settings from './SettingsStore' ;
@@ -154,6 +154,10 @@ export default types
154154 users : types . optional ( types . array ( UserExtended ) , [ ] ) ,
155155
156156 userLabels : isFF ( FF_DEV_1536 ) ? types . optional ( UserLabels , { controls : { } } ) : types . undefined ,
157+
158+ queueTotal : types . optional ( types . number , 0 ) ,
159+
160+ queuePosition : types . optional ( types . number , 0 ) ,
157161 } )
158162 . preProcessSnapshot ( ( sn ) => {
159163 // This should only be handled if the sn.user value is an object, and converted to a reference id for other
@@ -529,6 +533,9 @@ export default types
529533 } )
530534 . then ( ( ) => self . setFlags ( { isSubmitting : false } ) ) ;
531535 }
536+ function incrementQueuePosition ( number = 1 ) {
537+ self . queuePosition = clamp ( self . queuePosition + number , 1 , self . queueTotal ) ;
538+ }
532539
533540 function submitAnnotation ( ) {
534541 if ( self . isSubmitting ) return ;
@@ -543,6 +550,7 @@ export default types
543550 entity . sendUserGenerate ( ) ;
544551 handleSubmittingFlag ( async ( ) => {
545552 await getEnv ( self ) . events . invoke ( event , self , entity ) ;
553+ self . incrementQueuePosition ( ) ;
546554 } ) ;
547555 entity . dropDraft ( ) ;
548556 }
@@ -558,6 +566,7 @@ export default types
558566
559567 handleSubmittingFlag ( async ( ) => {
560568 await getEnv ( self ) . events . invoke ( 'updateAnnotation' , self , entity , extraData ) ;
569+ self . incrementQueuePosition ( ) ;
561570 } ) ;
562571 entity . dropDraft ( ) ;
563572 ! entity . sentUserGenerate && entity . sendUserGenerate ( ) ;
@@ -567,6 +576,7 @@ export default types
567576 if ( self . isSubmitting ) return ;
568577 handleSubmittingFlag ( ( ) => {
569578 getEnv ( self ) . events . invoke ( 'skipTask' , self , extraData ) ;
579+ self . incrementQueuePosition ( ) ;
570580 } , 'Error during skip, try again' ) ;
571581 }
572582
@@ -590,6 +600,7 @@ export default types
590600
591601 entity . dropDraft ( ) ;
592602 await getEnv ( self ) . events . invoke ( 'acceptAnnotation' , self , { isDirty, entity } ) ;
603+ self . incrementQueuePosition ( ) ;
593604 } , 'Error during accept, try again' ) ;
594605 }
595606
@@ -606,6 +617,8 @@ export default types
606617
607618 entity . dropDraft ( ) ;
608619 await getEnv ( self ) . events . invoke ( 'rejectAnnotation' , self , { isDirty, entity, comment } ) ;
620+ self . incrementQueuePosition ( - 1 ) ;
621+
609622 } , 'Error during reject, try again' ) ;
610623 }
611624
@@ -754,14 +767,20 @@ export default types
754767 // or annotation created from prediction
755768 await annotation . saveDraft ( { was_postponed : true } ) ;
756769 await getEnv ( self ) . events . invoke ( 'nextTask' ) ;
770+ self . incrementQueuePosition ( ) ;
771+
757772 }
758773
759774 function nextTask ( ) {
775+
760776 if ( self . canGoNextTask ) {
761777 const { taskId, annotationId } = self . taskHistory [ self . taskHistory . findIndex ( ( x ) => x . taskId === self . task . id ) + 1 ] ;
762778
763779 getEnv ( self ) . events . invoke ( 'nextTask' , taskId , annotationId ) ;
780+ self . incrementQueuePosition ( ) ;
781+
764782 }
783+
765784 }
766785
767786 function prevTask ( e , shouldGoBack = false ) {
@@ -771,6 +790,8 @@ export default types
771790 const { taskId, annotationId } = self . taskHistory [ length ] ;
772791
773792 getEnv ( self ) . events . invoke ( 'prevTask' , taskId , annotationId ) ;
793+ self . incrementQueuePosition ( - 1 ) ;
794+
774795 }
775796 }
776797
@@ -826,6 +847,7 @@ export default types
826847 nextTask,
827848 prevTask,
828849 postponeTask,
850+ incrementQueuePosition,
829851 beforeDestroy ( ) {
830852 ToolsManager . removeAllTools ( ) ;
831853 appControls = null ;
0 commit comments