@@ -7,7 +7,7 @@ import { UserRole } from "@/src/types/shared/sidebar";
77import { LabelingSuiteManager } from "@/src/util/classes/labeling/manager" ;
88import { SessionManager } from "@/src/util/classes/labeling/session-manager" ;
99import { UserManager } from "@/src/util/classes/labeling/user-manager" ;
10- import { DUMMY_HUDDLE_ID , getDefaultLabelingSuiteSettings , parseLabelingLink } from "@/src/util/components/projects/projectId/labeling/labeling-main-component-helper" ;
10+ import { DUMMY_HUDDLE_ID , getDefaultLabelingSuiteSettings , parseLabelingLink , prepareRLADataForRole } from "@/src/util/components/projects/projectId/labeling/labeling-main-component-helper" ;
1111import { useLazyQuery } from "@apollo/client" ;
1212import { useRouter } from "next/router" ;
1313import { useCallback , useEffect , useState } from "react" ;
@@ -152,7 +152,7 @@ export default function LabelingMainComponent() {
152152 } , [ projectId ] ) ;
153153
154154 useEffect ( ( ) => {
155- if ( ! projectId || allUsers . length == 0 || ! router . query . sessionId ) return ;
155+ if ( ! projectId || allUsers . length == 0 || ! router . query . sessionId || ! user ) return ;
156156 if ( router . query . sessionId == DUMMY_HUDDLE_ID ) return ;
157157 if ( ! SessionManager . currentRecordId ) return ;
158158 if ( SessionManager . currentRecordId == "deleted" ) return ;
@@ -174,9 +174,10 @@ export default function LabelingMainComponent() {
174174 ] ) . subscribe ( ( [ tokenized , record , rla ] ) => {
175175 dispatch ( updateRecordRequests ( 'token' , tokenized . data . tokenizeRecord ) ) ;
176176 dispatch ( updateRecordRequests ( 'record' , record . data . recordByRecordId ) ) ;
177- dispatch ( updateRecordRequests ( 'rla' , rla ?. data ?. recordByRecordId ?. recordLabelAssociations ) ) ;
177+ const rlas = rla [ 'data' ] ?. [ 'recordByRecordId' ] ?. [ 'recordLabelAssociations' ] [ 'edges' ] . map ( e => e . node ) ; ;
178+ dispatch ( updateRecordRequests ( 'rla' , prepareRLADataForRole ( rlas , user , userDisplayId , userDisplayRole ) ) ) ;
178179 } ) ;
179- } , [ SessionManager . currentRecordId ] ) ;
180+ } , [ SessionManager . currentRecordId , user ] ) ;
180181
181182 useEffect ( ( ) => {
182183 if ( ! rlas || ! user ) return ;
@@ -303,8 +304,12 @@ export default function LabelingMainComponent() {
303304
304305 function prepareTasksForRole ( taskData : LabelingTask [ ] , userDisplayRole ) : LabelingTask [ ] {
305306 if ( user ?. role != UserRole . ANNOTATOR && userDisplayRole != UserRole . ANNOTATOR ) return taskData ;
306- if ( ! JSON . parse ( localStorage . getItem ( 'huddleData' ) ) ) return null ;
307- const taskId = JSON . parse ( localStorage . getItem ( 'huddleData' ) ) . allowedTask ;
307+ let taskId ;
308+ if ( userDisplayRole != UserRole . ENGINEER ) {
309+ taskId = JSON . parse ( localStorage . getItem ( 'huddleData' ) ) ?. allowedTask ;
310+ } else {
311+ taskId = JSON . parse ( localStorage . getItem ( 'huddleData' ) ) . allowedTask ;
312+ }
308313 if ( ! taskId ) return null ;
309314 else return taskData . filter ( t => t . id == taskId ) ;
310315 }
@@ -324,7 +329,8 @@ export default function LabelingMainComponent() {
324329 } else if ( [ 'payload_finished' , 'weak_supervision_finished' , 'rla_created' , 'rla_deleted' ] . includes ( msgParts [ 1 ] ) ) {
325330 const recordId = SessionManager . currentRecordId ?? record . id ;
326331 refetchRla ( { variables : { projectId, recordId : recordId } } ) . then ( ( result ) => {
327- dispatch ( updateRecordRequests ( 'rla' , result ?. data ?. recordByRecordId ?. recordLabelAssociations ) ) ;
332+ const rlas = result [ 'data' ] ?. [ 'recordByRecordId' ] ?. [ 'recordLabelAssociations' ] [ 'edges' ] . map ( e => e . node ) ; ;
333+ dispatch ( updateRecordRequests ( 'rla' , prepareRLADataForRole ( rlas , user , userDisplayId , userDisplayRole ) ) ) ;
328334 } ) ;
329335 } else if ( [ 'access_link_changed' , 'access_link_removed' ] . includes ( msgParts [ 1 ] ) ) {
330336 if ( router . pathname . includes ( msgParts [ 3 ] ) && SessionManager . labelingLinkData ) {
0 commit comments