File tree Expand file tree Collapse file tree 5 files changed +49
-43
lines changed
apps/labelstudio/src/pages/DataManager Expand file tree Collapse file tree 5 files changed +49
-43
lines changed Original file line number Diff line number Diff line change 921921 },
922922 "fflag__feature_develop__prompts__dia_1829_jwt_token_auth" : {
923923 "key" : " fflag__feature_develop__prompts__dia_1829_jwt_token_auth" ,
924- "on" : false ,
924+ "on" : true ,
925925 "prerequisites" : [],
926926 "targets" : [],
927927 "contextTargets" : [],
27172717 },
27182718 "fflag_feat_front_optic_1746_improve_global_error_messages_short" : {
27192719 "key" : " fflag_feat_front_optic_1746_improve_global_error_messages_short" ,
2720- "on" : false ,
2720+ "on" : true ,
27212721 "prerequisites" : [],
27222722 "targets" : [],
27232723 "contextTargets" : [],
Original file line number Diff line number Diff line change @@ -60,7 +60,7 @@ const buildLink = (path, params) => {
6060} ;
6161
6262export const DataManagerPage = ( { ...props } ) => {
63- const dependencies = useMemo ( loadDependencies ) ;
63+ const dependencies = useMemo ( loadDependencies , [ ] ) ;
6464 const toast = useContext ( ToastContext ) ;
6565 const root = useRef ( ) ;
6666 const params = useParams ( ) ;
@@ -192,32 +192,18 @@ export const DataManagerPage = ({ ...props }) => {
192192 dataManagerRef . current . destroy ( ) ;
193193 dataManagerRef . current = null ;
194194 }
195- } , [ dataManagerRef ] ) ;
195+ } , [ ] ) ;
196196
197197 useEffect ( ( ) => {
198198 Promise . all ( dependencies )
199199 . then ( ( ) => setLoading ( false ) )
200200 . then ( init ) ;
201+ } , [ init ] ) ;
201202
203+ useEffect ( ( ) => {
204+ // destroy the data manager when the component is unmounted
202205 return ( ) => destroyDM ( ) ;
203- } , [ root , init ] ) ;
204-
205- if ( loading ) {
206- return (
207- < div
208- style = { {
209- flex : 1 ,
210- width : "100%" ,
211- height : "100%" ,
212- display : "flex" ,
213- alignItems : "center" ,
214- justifyContent : "center" ,
215- } }
216- >
217- < Spinner size = { 64 } />
218- </ div >
219- ) ;
220- }
206+ } , [ ] ) ;
221207
222208 return crashed ? (
223209 < Block name = "crash" >
@@ -226,7 +212,28 @@ export const DataManagerPage = ({ ...props }) => {
226212 < Button to = "/projects" > Back to projects</ Button >
227213 </ Block >
228214 ) : (
229- < Block ref = { root } name = "datamanager" />
215+ < >
216+ { loading && (
217+ < div
218+ style = { {
219+ flex : 1 ,
220+ position : "absolute" ,
221+ top : 0 ,
222+ left : 0 ,
223+ right : 0 ,
224+ bottom : 0 ,
225+ width : "100%" ,
226+ height : "100%" ,
227+ display : "flex" ,
228+ alignItems : "center" ,
229+ justifyContent : "center" ,
230+ } }
231+ >
232+ < Spinner size = { 64 } />
233+ </ div >
234+ ) }
235+ < Block ref = { root } name = "datamanager" />
236+ </ >
230237 ) ;
231238} ;
232239
Original file line number Diff line number Diff line change @@ -72,33 +72,23 @@ export const Labeling = injector(
7272 } , [ ] ) ;
7373
7474 useEffect ( ( ) => {
75- const onTaskSelected = ( ) => {
76- // Destroy LSF and initialize it again to avoid issues with the LSF instance
77- // being unavailable when the component is remounted.
78- // This is to best align the cases where LSF is initialized by a page load
79- // or a task navigation, and avoid issues with the task initialization not properly
80- // allowing deep linking to work due to the LSF instance being destroyed right before
81- // the task would be loaded.
82- SDK . destroyLSF ( ) ;
83- initLabeling ( ) ;
84- } ;
85-
86- if ( ! isLabelStream ) SDK . on ( "taskSelected" , onTaskSelected ) ;
75+ if ( ! isLabelStream ) SDK . on ( "taskSelected" , initLabeling ) ;
8776
8877 return ( ) => {
89- if ( ! isLabelStream ) SDK . off ( "taskSelected" , onTaskSelected ) ;
78+ if ( ! isLabelStream ) SDK . off ( "taskSelected" , initLabeling ) ;
9079 } ;
9180 } , [ ] ) ;
9281
9382 useEffect ( ( ) => {
9483 if ( ( ! SDK . lsf && store . dataStore . selected ) || isLabelStream ) {
9584 initLabeling ( ) ;
96-
97- // destroy LSF when component unmounts and was initialized by this component and not the "taskSelected" event
98- return ( ) => SDK . destroyLSF ( ) ;
9985 }
10086 } , [ ] ) ;
10187
88+ useEffect ( ( ) => {
89+ return ( ) => SDK . destroyLSF ( ) ;
90+ } , [ ] ) ;
91+
10292 const onResize = useCallback ( ( width ) => {
10393 view . setLabelingTableWidth ( width ) ;
10494 // trigger resize events inside LSF
Original file line number Diff line number Diff line change @@ -45,7 +45,7 @@ const DEFAULT_INTERFACES = [
4545
4646let LabelStudioDM ;
4747
48- const resolveLabelStudio = async ( ) => {
48+ const resolveLabelStudio = ( ) => {
4949 if ( LabelStudioDM ) {
5050 return LabelStudioDM ;
5151 }
@@ -223,9 +223,9 @@ export class LSFWrapper {
223223 }
224224
225225 /** @private */
226- async initLabelStudio ( settings ) {
226+ initLabelStudio ( settings ) {
227227 try {
228- const LSF = await resolveLabelStudio ( ) ;
228+ const LSF = resolveLabelStudio ( ) ;
229229
230230 this . lsfInstance = new LSF ( this . root , settings ) ;
231231
Original file line number Diff line number Diff line change @@ -198,14 +198,23 @@ export const AppStore = types
198198 } ,
199199
200200 setTask : flow ( function * ( { taskID, annotationID, pushState } ) {
201- console . trace ( "setTask" ) ;
202201 if ( pushState !== false ) {
203202 History . navigate ( {
204203 task : taskID ,
205204 annotation : annotationID ?? null ,
206205 interaction : null ,
207206 region : null ,
208207 } ) ;
208+ } else if ( isFF ( FF_REGION_VISIBILITY_FROM_URL ) ) {
209+ const { task, region, annotation } = History . getParams ( ) ;
210+ History . navigate (
211+ {
212+ task,
213+ region,
214+ annotation,
215+ } ,
216+ true ,
217+ ) ;
209218 }
210219
211220 if ( ! isDefined ( taskID ) ) return ;
You can’t perform that action at this time.
0 commit comments