@@ -15,7 +15,6 @@ import {
1515 ActionIcon ,
1616 Button ,
1717 Divider ,
18- FileButton ,
1918 Modal ,
2019 NumberInput ,
2120 Progress ,
@@ -117,10 +116,6 @@ export default function Missions() {
117116 const tabsListRef = useRef ( null )
118117 const [ tableSectionHeight , setTableSectionHeight ] = useState ( 300 )
119118
120- // File import handling
121- const [ importFile , setImportFile ] = useState ( null )
122- const importFileResetRef = useRef ( null )
123-
124119 // Modal for mission progress
125120 const [ missionProgressModalTitle , setMissionProgressModalTitle ] = useState (
126121 "Mission progress update" ,
@@ -152,12 +147,6 @@ export default function Missions() {
152147 dispatch ( emitGetTargetInfo ( ) )
153148 } , [ currentPage ] )
154149
155- useEffect ( ( ) => {
156- if ( importFile ) {
157- importMissionFromFile ( importFile . path )
158- }
159- } , [ importFile ] )
160-
161150 useEffect ( ( ) => {
162151 activeTabRef . current = activeTab
163152 } , [ activeTab ] )
@@ -245,17 +234,19 @@ export default function Missions() {
245234 dispatch ( setMissionProgressModal ( true ) )
246235 }
247236
248- function importMissionFromFile ( filePath ) {
249- dispatch (
250- emitImportMissionFromFile ( {
251- type : activeTabRef . current ,
252- file_path : filePath ,
253- } ) ,
237+ async function importMissionFromFile ( ) {
238+ const result = await window . ipcRenderer . invoke (
239+ "window:select-file-in-explorer" ,
240+ [ { name : "Waypoint files" , extensions : [ "waypoints" , "txt" ] } ] ,
254241 )
255-
256- // Reset the import file after sending
257- setImportFile ( null )
258- importFileResetRef . current ?. ( )
242+ if ( result ) {
243+ dispatch (
244+ emitImportMissionFromFile ( {
245+ type : activeTabRef . current ,
246+ file_path : result . path ,
247+ } ) ,
248+ )
249+ }
259250 }
260251
261252 async function saveMissionToFile ( ) {
@@ -414,14 +405,9 @@ export default function Missions() {
414405 < Divider className = "my-1" />
415406
416407 < div className = "flex flex-col gap-4" >
417- < FileButton
418- resetRef = { importFileResetRef }
419- onChange = { setImportFile }
420- accept = ".waypoints,.txt"
421- className = "grow"
422- >
423- { ( props ) => < Button { ...props } > Import from file</ Button > }
424- </ FileButton >
408+ < Button className = "grow" onClick = { importMissionFromFile } >
409+ Import from file
410+ </ Button >
425411 < Button
426412 onClick = { ( ) => {
427413 saveMissionToFile ( )
0 commit comments