From 68b3de9b7f321b02bb6d83cd0adf58b83cd7aaae Mon Sep 17 00:00:00 2001 From: Chubby Granny Chaser Date: Wed, 22 Oct 2025 17:37:00 +0100 Subject: [PATCH] fix: moving constant --- src/main/constants.ts | 5 +++++ src/main/services/screenshot.ts | 10 +++++----- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/main/constants.ts b/src/main/constants.ts index 82b99b2a..d1c3b411 100644 --- a/src/main/constants.ts +++ b/src/main/constants.ts @@ -31,6 +31,11 @@ export const logsPath = path.join( `logs${isStaging ? "-staging" : ""}` ); +export const screenshotsPath = path.join( + SystemPath.getPath("userData"), + "Screenshots" +); + export const achievementSoundPath = app.isPackaged ? path.join(process.resourcesPath, "achievement.wav") : path.join(__dirname, "..", "..", "resources", "achievement.wav"); diff --git a/src/main/services/screenshot.ts b/src/main/services/screenshot.ts index 7f1a2cc9..c8636890 100644 --- a/src/main/services/screenshot.ts +++ b/src/main/services/screenshot.ts @@ -2,6 +2,7 @@ import { desktopCapturer, nativeImage, app } from "electron"; import fs from "node:fs"; import path from "node:path"; import { logger } from "./logger"; +import { screenshotsPath } from "@main/constants"; export class ScreenshotService { private static readonly SCREENSHOT_QUALITY = 80; @@ -50,6 +51,8 @@ export class ScreenshotService { throw new Error("No desktop sources available for screenshot"); } + console.log("sources", sources); + const primaryScreen = sources[0]; const originalImage = nativeImage.createFromDataURL( @@ -58,15 +61,12 @@ export class ScreenshotService { const compressedImage = this.compressImage(originalImage); - const userDataPath = app.getPath("userData"); - const screenshotsDir = path.join(userDataPath, "screenshots"); - - let finalDir = screenshotsDir; + let finalDir = screenshotsPath; let filename: string; if (gameTitle && achievementName) { const sanitizedGameTitle = gameTitle.replaceAll(/[<>:"/\\|?*]/g, "_"); - const gameDir = path.join(screenshotsDir, sanitizedGameTitle); + const gameDir = path.join(screenshotsPath, sanitizedGameTitle); finalDir = gameDir; const sanitizedAchievementName = achievementName.replaceAll(