@@ -6,6 +6,7 @@ import useElectron from "../use-electron.js"
66import { useToasts } from "../../components/Toasts"
77import templates from "../../components/StartingPage/templates.js"
88import { setIn } from "seamless-immutable"
9+ import toUDTCSV from "../to-udt-csv.js"
910import useIsDesktop from "../use-is-desktop"
1011
1112const webReturn = { saveFile : ( ) => null }
@@ -24,10 +25,15 @@ export default (file, changeFile) => {
2425 cancelled,
2526 filePath : newFilePath ,
2627 } = await remote . dialog . showSaveDialog ( {
27- filters : [ { name : ".udt.json" , extensions : [ "udt.json" ] } ] ,
28+ filters : [
29+ { name : ".udt.json" , extensions : [ "udt.json" ] } ,
30+ { name : ".udt.csv" , extensions : [ "udt.csv" ] } ,
31+ ] ,
2832 } )
2933 filePath =
30- ! newFilePath || newFilePath . endsWith ( ".json" )
34+ ! newFilePath ||
35+ newFilePath . endsWith ( ".json" ) ||
36+ newFilePath . endsWith ( ".csv" )
3137 ? newFilePath
3238 : `${ newFilePath } .udt.json`
3339 if ( cancelled || ! filePath ) {
@@ -42,7 +48,12 @@ export default (file, changeFile) => {
4248 }
4349 await remote
4450 . require ( "fs" )
45- . promises . writeFile ( filePath , JSON . stringify ( file . content , null , " " ) )
51+ . promises . writeFile (
52+ filePath ,
53+ filePath . endsWith ( ".csv" )
54+ ? toUDTCSV ( file . content )
55+ : JSON . stringify ( file . content , null , " " )
56+ )
4657 addToast ( "File Saved!" )
4758 }
4859 saveFileAsync ( )
0 commit comments