Fix up export

This commit is contained in:
49lf
2024-07-31 15:31:36 -04:00
parent beeece61fa
commit 53467ee954
3 changed files with 12 additions and 9 deletions

View File

@ -3,7 +3,8 @@ import path from 'path'
import fs from 'node:fs/promises' import fs from 'node:fs/promises'
import packageJson from '../../package.json' import packageJson from '../../package.json'
const open = (args: any) => ipcRenderer.invoke('dialog', args) const open = (args: any) => ipcRenderer.invoke('dialog.showOpenDialog', args)
const save = (args: any) => ipcRenderer.invoke('dialog.showSaveDialog', args)
const openExternal = (url: any) => ipcRenderer.invoke('shell.openExternal', url) const openExternal = (url: any) => ipcRenderer.invoke('shell.openExternal', url)
const showInFolder = (path: string) => ipcRenderer.invoke('shell.showItemInFolder', path) const showInFolder = (path: string) => ipcRenderer.invoke('shell.showItemInFolder', path)
const login = (host: string) => ipcRenderer.invoke('login', host) const login = (host: string) => ipcRenderer.invoke('login', host)
@ -48,6 +49,7 @@ import('@kittycad/lib').then((kittycad) => {
mkdir: fs.mkdir, mkdir: fs.mkdir,
// opens a dialog // opens a dialog
open, open,
save,
// opens the URL // opens the URL
openExternal, openExternal,
showInFolder, showInFolder,

View File

@ -15,7 +15,7 @@ const save_ = async (file: ModelingAppFile) => {
} }
// Open a dialog to save the file. // Open a dialog to save the file.
const filePath = await window.electron.save({ const filePathMeta = await window.electron.save({
defaultPath: file.name, defaultPath: file.name,
filters: [ filters: [
{ {
@ -25,14 +25,12 @@ const save_ = async (file: ModelingAppFile) => {
], ],
}) })
if (filePath === null) { // The user canceled the save.
// The user canceled the save. // Return early.
// Return early. if (filePathMeta.canceled) return
return
}
// Write the file. // Write the file.
await window.electron.writeFile(filePath, new Uint8Array(file.contents)) await window.electron.writeFile(filePathMeta.filePath, new Uint8Array(file.contents))
} else { } else {
// Download the file to the user's computer. // Download the file to the user's computer.
// Now we need to download the files to the user's downloads folder. // Now we need to download the files to the user's downloads folder.

View File

@ -55,9 +55,12 @@ ipcMain.handle('app.getPath', (event, data) => {
return app.getPath(data) return app.getPath(data)
}) })
ipcMain.handle('dialog', (event, data) => { ipcMain.handle('dialog.showOpenDialog', (event, data) => {
return dialog.showOpenDialog(data) return dialog.showOpenDialog(data)
}) })
ipcMain.handle('dialog.showSaveDialog', (event, data) => {
return dialog.showSaveDialog(data)
})
ipcMain.handle('shell.showItemInFolder', (event, data) => { ipcMain.handle('shell.showItemInFolder', (event, data) => {
return shell.showItemInFolder(data) return shell.showItemInFolder(data)