@@ -40,15 +40,22 @@ const EditorUnplugged: FC<{ t: TFunction }> = ({ t }) => {
40
40
const [ toolState , setToolState ] = useState < any > ( activeTool . getInitialState ( { osrdConf } ) ) ;
41
41
const [ modal , setModal ] = useState < ModalRequest < any , any > | null > ( null ) ;
42
42
/* eslint-enable @typescript-eslint/no-explicit-any */
43
+ const openModal = useCallback (
44
+ < ArgumentsType , SubmitArgumentsType > (
45
+ request : ModalRequest < ArgumentsType , SubmitArgumentsType >
46
+ ) => {
47
+ setModal ( request as ModalRequest < unknown , unknown > ) ;
48
+ } ,
49
+ [ setModal ]
50
+ ) ;
43
51
44
- const { infra, urlLat, urlLon, urlZoom, urlBearing, urlPitch } =
45
- useParams < Record < string , string > > ( ) ;
52
+ const { infra } = useParams < { infra ?: string } > ( ) ;
46
53
const { mapStyle, viewport } = useSelector (
47
54
( state : { map : { mapStyle : string ; viewport : ViewportProps } } ) => state . map
48
55
) ;
49
56
const setViewport = useCallback (
50
57
( value ) => {
51
- dispatch ( updateViewport ( value , `/editor/${ osrdConf . infraID || '-1' } ` ) ) ;
58
+ dispatch ( updateViewport ( value , `/editor/${ osrdConf . infraID || '-1' } ` , false ) ) ;
52
59
} ,
53
60
[ dispatch , osrdConf . infraID ]
54
61
) ;
@@ -57,11 +64,7 @@ const EditorUnplugged: FC<{ t: TFunction }> = ({ t }) => {
57
64
( ) => ( {
58
65
t,
59
66
modal,
60
- openModal : < ArgumentsType , SubmitArgumentsType > (
61
- request : ModalRequest < ArgumentsType , SubmitArgumentsType >
62
- ) => {
63
- setModal ( request as ModalRequest < unknown , unknown > ) ;
64
- } ,
67
+ openModal,
65
68
closeModal : ( ) => {
66
69
setModal ( null ) ;
67
70
} ,
@@ -98,17 +101,6 @@ const EditorUnplugged: FC<{ t: TFunction }> = ({ t }) => {
98
101
useEffect ( ( ) => {
99
102
// load the data model
100
103
dispatch ( loadDataModel ( ) ) ;
101
- if ( urlLat ) {
102
- setViewport ( {
103
- ...viewport ,
104
- latitude : parseFloat ( urlLat || '0' ) ,
105
- longitude : parseFloat ( urlLon || '0' ) ,
106
- zoom : parseFloat ( urlZoom || '1' ) ,
107
- bearing : parseFloat ( urlBearing || '1' ) ,
108
- pitch : parseFloat ( urlPitch || '1' ) ,
109
- } ) ;
110
- }
111
- // eslint-disable-next-line react-hooks/exhaustive-deps
112
104
} , [ ] ) ;
113
105
114
106
// Update the infrastructure in state
@@ -139,7 +131,7 @@ const EditorUnplugged: FC<{ t: TFunction }> = ({ t }) => {
139
131
dispatch ( setFailure ( new Error ( t ( 'Editor.errors.technical' , { msg : e . message } ) ) ) ) ;
140
132
} ) ;
141
133
}
142
- } , [ dispatch , infra , osrdConf . infraID , t ] ) ;
134
+ } , [ infra , osrdConf . infraID ] ) ;
143
135
144
136
// Lifecycle events on tools:
145
137
useEffect ( ( ) => {
@@ -267,7 +259,7 @@ const EditorUnplugged: FC<{ t: TFunction }> = ({ t }) => {
267
259
) }
268
260
onClick = { ( ) => {
269
261
if ( onClick ) {
270
- onClick ( { dispatch, setViewport, viewport } , editorState ) ;
262
+ onClick ( { dispatch, setViewport, viewport, openModal } , editorState ) ;
271
263
}
272
264
} }
273
265
disabled = { isDisabled && isDisabled ( editorState ) }
0 commit comments