summaryrefslogtreecommitdiff
path: root/src/main/manaplus/manaplus.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/manaplus/manaplus.ts')
-rw-r--r--src/main/manaplus/manaplus.ts24
1 files changed, 12 insertions, 12 deletions
diff --git a/src/main/manaplus/manaplus.ts b/src/main/manaplus/manaplus.ts
index 15a3282..3a4a6f5 100644
--- a/src/main/manaplus/manaplus.ts
+++ b/src/main/manaplus/manaplus.ts
@@ -115,19 +115,19 @@ please check you network connection first.",
}
}
-ipcMain.on("getScreenshots", (event: any, arg: string) => {
+ipcMain.handle("getScreenshots", async (_event: any, arg: string) => {
const screenshotsDir = join(getUserDataPath(), "/screenshots/", `${arg}/`);
- fs.existsSync(screenshotsDir) || fs.mkdirSync(screenshotsDir);
- fs.readdir(screenshotsDir, (err, dir) => {
- let screenshots: string[] = [];
- for (var i = 0, path; (path = dir[i]); i++) {
- screenshots.push(path);
- }
- event.sender.send("getScreenshots", {
- dir: screenshotsDir,
- screenshots: screenshots.reverse().slice(0, 24),
- });
- });
+ (await fs.existsSync(screenshotsDir)) || (await fs.mkdirSync(screenshotsDir));
+ const dir = await fs.readdir(screenshotsDir);
+
+ let screenshots: string[] = [];
+ for (var i = 0, path; (path = dir[i]); i++) {
+ screenshots.push(path);
+ }
+ return {
+ dir: screenshotsDir,
+ screenshots: screenshots.reverse().slice(0, 24),
+ };
});
EventEmitter.on("Mana:openScreenshotDir", () => {