mirror of
https://github.com/hydralauncher/hydra.git
synced 2026-01-31 06:41:03 +00:00
feat: added open screenshots folder in settings-behavior
This commit is contained in:
@@ -526,6 +526,7 @@
|
||||
"extract_files_by_default": "Extract files by default after download",
|
||||
"enable_steam_achievements": "Enable search for Steam achievements",
|
||||
"enable_achievement_screenshots": "Enable achievement screenshots",
|
||||
"open_screenshots_directory": "Open screenshots directory",
|
||||
"achievement_custom_notification_position": "Achievement custom notification position",
|
||||
"top-left": "Top left",
|
||||
"top-center": "Top center",
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { appVersion, defaultDownloadsPath, isStaging } from "@main/constants";
|
||||
import { appVersion, defaultDownloadsPath, isStaging, screenshotsPath } from "@main/constants";
|
||||
import { ipcMain } from "electron";
|
||||
|
||||
import "./catalogue/get-game-shop-details";
|
||||
@@ -38,6 +38,7 @@ import "./library/create-steam-shortcut";
|
||||
import "./library/copy-custom-game-asset";
|
||||
import "./misc/open-checkout";
|
||||
import "./misc/open-external";
|
||||
import "./misc/open-folder";
|
||||
import "./misc/show-open-dialog";
|
||||
import "./misc/show-item-in-folder";
|
||||
import "./misc/install-common-redist";
|
||||
@@ -107,3 +108,4 @@ ipcMain.handle("getVersion", () => appVersion);
|
||||
ipcMain.handle("isStaging", () => isStaging);
|
||||
ipcMain.handle("isPortableVersion", () => isPortableVersion());
|
||||
ipcMain.handle("getDefaultDownloadsPath", () => defaultDownloadsPath);
|
||||
ipcMain.handle("getScreenshotsPath", () => screenshotsPath);
|
||||
|
||||
11
src/main/events/misc/open-folder.ts
Normal file
11
src/main/events/misc/open-folder.ts
Normal file
@@ -0,0 +1,11 @@
|
||||
import { shell } from "electron";
|
||||
import { registerEvent } from "../register-event";
|
||||
|
||||
const openFolder = async (
|
||||
_event: Electron.IpcMainInvokeEvent,
|
||||
folderPath: string
|
||||
) => {
|
||||
return shell.openPath(folderPath);
|
||||
};
|
||||
|
||||
registerEvent("openFolder", openFolder);
|
||||
@@ -344,9 +344,11 @@ contextBridge.exposeInMainWorld("electron", {
|
||||
ping: () => ipcRenderer.invoke("ping"),
|
||||
getVersion: () => ipcRenderer.invoke("getVersion"),
|
||||
getDefaultDownloadsPath: () => ipcRenderer.invoke("getDefaultDownloadsPath"),
|
||||
getScreenshotsPath: () => ipcRenderer.invoke("getScreenshotsPath"),
|
||||
isStaging: () => ipcRenderer.invoke("isStaging"),
|
||||
isPortableVersion: () => ipcRenderer.invoke("isPortableVersion"),
|
||||
openExternal: (src: string) => ipcRenderer.invoke("openExternal", src),
|
||||
openFolder: (path: string) => ipcRenderer.invoke("openFolder", path),
|
||||
openCheckout: () => ipcRenderer.invoke("openCheckout"),
|
||||
showOpenDialog: (options: Electron.OpenDialogOptions) =>
|
||||
ipcRenderer.invoke("showOpenDialog", options),
|
||||
|
||||
@@ -1,6 +1,12 @@
|
||||
import { darkenColor } from "@renderer/helpers";
|
||||
import { useAppSelector, useToast } from "@renderer/hooks";
|
||||
import type { Badge, UserProfile, UserStats, UserGame, ProfileAchievement } from "@types";
|
||||
import type {
|
||||
Badge,
|
||||
UserProfile,
|
||||
UserStats,
|
||||
UserGame,
|
||||
ProfileAchievement,
|
||||
} from "@types";
|
||||
import { average } from "color.js";
|
||||
|
||||
import { createContext, useCallback, useEffect, useState } from "react";
|
||||
@@ -150,17 +156,19 @@ export function UserProfileContextProvider({
|
||||
|
||||
// Fetch achievements separately
|
||||
const achievementsPromise = window.electron.hydraApi
|
||||
.get<ProfileAchievement[]>(`/users/${userId}/achievements?${params.toString()}`)
|
||||
.get<
|
||||
ProfileAchievement[]
|
||||
>(`/users/${userId}/achievements?${params.toString()}`)
|
||||
.catch(() => null); // If achievements fail, just return null
|
||||
|
||||
return Promise.all([profilePromise, achievementsPromise])
|
||||
.then(([userProfile, achievements]) => {
|
||||
return Promise.all([profilePromise, achievementsPromise]).then(
|
||||
([userProfile, achievements]) => {
|
||||
// Merge achievements into the profile
|
||||
const profileWithAchievements = {
|
||||
...userProfile,
|
||||
achievements: achievements || null,
|
||||
};
|
||||
|
||||
|
||||
setUserProfile(profileWithAchievements);
|
||||
|
||||
if (userProfile.profileImageUrl) {
|
||||
@@ -168,7 +176,8 @@ export function UserProfileContextProvider({
|
||||
(color) => setHeroBackground(color)
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
);
|
||||
}, [
|
||||
navigate,
|
||||
getUserStats,
|
||||
|
||||
2
src/renderer/src/declaration.d.ts
vendored
2
src/renderer/src/declaration.d.ts
vendored
@@ -276,7 +276,9 @@ declare global {
|
||||
isStaging: () => Promise<boolean>;
|
||||
ping: () => string;
|
||||
getDefaultDownloadsPath: () => Promise<string>;
|
||||
getScreenshotsPath: () => Promise<string>;
|
||||
isPortableVersion: () => Promise<boolean>;
|
||||
openFolder: (path: string) => Promise<string>;
|
||||
showOpenDialog: (
|
||||
options: Electron.OpenDialogOptions
|
||||
) => Promise<Electron.OpenDialogReturnValue>;
|
||||
|
||||
@@ -21,4 +21,8 @@
|
||||
cursor: pointer;
|
||||
}
|
||||
}
|
||||
|
||||
&__button-container {
|
||||
margin-top: 16px;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { useContext, useEffect, useState } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
|
||||
import { CheckboxField } from "@renderer/components";
|
||||
import { CheckboxField, Button } from "@renderer/components";
|
||||
import { useAppSelector } from "@renderer/hooks";
|
||||
import { settingsContext } from "@renderer/context";
|
||||
import "./settings-behavior.scss";
|
||||
@@ -210,6 +210,18 @@ export function SettingsBehavior() {
|
||||
<QuestionIcon size={12} />
|
||||
</small>
|
||||
</div>
|
||||
|
||||
<div className="settings-behavior__button-container">
|
||||
<Button
|
||||
theme="outline"
|
||||
onClick={async () => {
|
||||
const screenshotsPath = await window.electron.getScreenshotsPath();
|
||||
window.electron.openFolder(screenshotsPath);
|
||||
}}
|
||||
>
|
||||
{t("open_screenshots_directory")}
|
||||
</Button>
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user