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 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 showInFolder = (path: string) => ipcRenderer.invoke('shell.showItemInFolder', path)
const login = (host: string) => ipcRenderer.invoke('login', host)
@ -48,6 +49,7 @@ import('@kittycad/lib').then((kittycad) => {
mkdir: fs.mkdir,
// opens a dialog
open,
save,
// opens the URL
openExternal,
showInFolder,

View File

@ -15,7 +15,7 @@ const save_ = async (file: ModelingAppFile) => {
}
// Open a dialog to save the file.
const filePath = await window.electron.save({
const filePathMeta = await window.electron.save({
defaultPath: file.name,
filters: [
{
@ -25,14 +25,12 @@ const save_ = async (file: ModelingAppFile) => {
],
})
if (filePath === null) {
// The user canceled the save.
// Return early.
return
}
if (filePathMeta.canceled) return
// Write the file.
await window.electron.writeFile(filePath, new Uint8Array(file.contents))
await window.electron.writeFile(filePathMeta.filePath, new Uint8Array(file.contents))
} else {
// Download the file to the user's computer.
// 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)
})
ipcMain.handle('dialog', (event, data) => {
ipcMain.handle('dialog.showOpenDialog', (event, data) => {
return dialog.showOpenDialog(data)
})
ipcMain.handle('dialog.showSaveDialog', (event, data) => {
return dialog.showSaveDialog(data)
})
ipcMain.handle('shell.showItemInFolder', (event, data) => {
return shell.showItemInFolder(data)