chore: refactor

This commit is contained in:
Louis 2023-09-30 12:54:25 +07:00 committed by Louis
parent 1a3c53c576
commit efc6db9e1a

View File

@ -39,7 +39,7 @@ const createMainWindow = () => {
ipcMain.handle(
"invokePluginFunc",
async (event, modulePath, method, ...args) => {
async (_event, modulePath, method, ...args) => {
const module = join(app.getPath("userData"), "plugins", modulePath);
return await import(/* webpackIgnore: true */ module)
.then((plugin) => {
@ -70,24 +70,6 @@ const createMainWindow = () => {
if (isDev) mainWindow.webContents.openDevTools();
};
const migratePlugins = () => {
return new Promise((resolve) => {
if (store.get("migrated_version") !== app.getVersion()) {
console.log("start migration:", store.get("migrated_version"));
const userDataPath = app.getPath("userData");
const fullPath = join(userDataPath, "plugins");
rmdir(fullPath, { recursive: true }, function (err) {
if (err) console.log(err);
store.set("migrated_version", app.getVersion());
console.log("migrate plugins done");
resolve(undefined);
});
} else {
resolve(undefined);
}
});
};
app
.whenReady()
@ -218,6 +200,25 @@ app.on("window-all-closed", () => {
}
});
function migratePlugins() {
return new Promise((resolve) => {
if (store.get("migrated_version") !== app.getVersion()) {
console.log("start migration:", store.get("migrated_version"));
const userDataPath = app.getPath("userData");
const fullPath = join(userDataPath, "plugins");
rmdir(fullPath, { recursive: true }, function (err) {
if (err) console.log(err);
store.set("migrated_version", app.getVersion());
console.log("migrate plugins done");
resolve(undefined);
});
} else {
resolve(undefined);
}
});
};
function setupPlugins() {
init({
// Function to check from the main process that user wants to install a plugin