added new openDirectory api

This commit is contained in:
Abhinav 2023-03-23 11:59:27 +05:30
parent bbd3d7aae9
commit fd60c5c826
3 changed files with 15 additions and 0 deletions

View file

@ -18,6 +18,15 @@ export const getAppVersion = async (): Promise<string> => {
} }
}; };
export const openDirectory = async (dirPath: string): Promise<void> => {
try {
await ipcRenderer.invoke('open-dir', dirPath);
} catch (e) {
logError(e, 'error while opening directory');
throw e;
}
};
export { export {
logToDisk, logToDisk,
openLogDirectory, openLogDirectory,

View file

@ -42,6 +42,7 @@ import {
openLogDirectory, openLogDirectory,
getSentryUserID, getSentryUserID,
getAppVersion, getAppVersion,
openDirectory,
} from './api/common'; } from './api/common';
import { fixHotReloadNext12 } from './utils/preload'; import { fixHotReloadNext12 } from './utils/preload';
import { isFolder, getDirFiles } from './api/fs'; import { isFolder, getDirFiles } from './api/fs';
@ -103,4 +104,5 @@ windowObject['ElectronAPIs'] = {
generateImageThumbnail, generateImageThumbnail,
logRendererProcessMemoryUsage, logRendererProcessMemoryUsage,
registerForegroundEventListener, registerForegroundEventListener,
openDirectory,
}; };

View file

@ -113,6 +113,10 @@ export default function setupIpcComs(
shell.openPath(app.getPath('logs')); shell.openPath(app.getPath('logs'));
}); });
ipcMain.handle('open-dir', (_, dirPath) => {
shell.openPath(dirPath);
});
ipcMain.on('update-and-restart', () => { ipcMain.on('update-and-restart', () => {
updateAndRestart(); updateAndRestart();
}); });