Implement save file (#108)

* Implement save file
* Delete locally downloaded files that have not been opened in last 7 days
This commit is contained in:
Hakan Shehu
2025-07-03 20:42:21 +02:00
committed by GitHub
parent b1c4069743
commit e8f56449d5
45 changed files with 1165 additions and 409 deletions

View File

@@ -5,6 +5,7 @@ import {
protocol,
shell,
globalShortcut,
dialog,
} from 'electron';
import started from 'electron-squirrel-startup';
@@ -251,3 +252,22 @@ ipcMain.handle(
ipcMain.handle('open-external-url', (_, url: string) => {
shell.openExternal(url);
});
ipcMain.handle('show-item-in-folder', (_, path: string) => {
shell.showItemInFolder(path);
});
ipcMain.handle(
'show-file-save-dialog',
async (_, { name }: { name: string }) => {
const result = await dialog.showSaveDialog({
defaultPath: name,
});
if (result.canceled) {
return undefined;
}
return result.filePath;
}
);

View File

@@ -55,6 +55,14 @@ contextBridge.exposeInMainWorld('colanode', {
openExternalUrl: async (url: string) => {
return ipcRenderer.invoke('open-external-url', url);
},
showItemInFolder: async (path: string) => {
return ipcRenderer.invoke('show-item-in-folder', path);
},
showFileSaveDialog: async ({ name }: { name: string }) => {
return ipcRenderer.invoke('show-file-save-dialog', { name });
},
});
contextBridge.exposeInMainWorld('eventBus', {