mirror of
https://github.com/hydralauncher/hydra.git
synced 2026-01-31 14:51:02 +00:00
fix: removed unused function
This commit is contained in:
@@ -24,7 +24,12 @@ import { UserFriendModal } from "./pages/shared-modals/user-friend-modal";
|
||||
import { useSubscription } from "./hooks/use-subscription";
|
||||
import { HydraCloudModal } from "./pages/shared-modals/hydra-cloud/hydra-cloud-modal";
|
||||
|
||||
import { injectCustomCss, removeCustomCss, getAchievementSoundUrl, getAchievementSoundVolume } from "./helpers";
|
||||
import {
|
||||
injectCustomCss,
|
||||
removeCustomCss,
|
||||
getAchievementSoundUrl,
|
||||
getAchievementSoundVolume,
|
||||
} from "./helpers";
|
||||
import "./app.scss";
|
||||
|
||||
export interface AppProps {
|
||||
|
||||
@@ -123,11 +123,12 @@ export const generateUUID = (): string => {
|
||||
};
|
||||
|
||||
export const getAchievementSoundUrl = async (): Promise<string> => {
|
||||
const defaultSound = (await import("@renderer/assets/audio/achievement.wav")).default;
|
||||
|
||||
const defaultSound = (await import("@renderer/assets/audio/achievement.wav"))
|
||||
.default;
|
||||
|
||||
try {
|
||||
const activeTheme = await window.electron.getActiveCustomTheme();
|
||||
|
||||
|
||||
if (activeTheme?.hasCustomSound) {
|
||||
const soundPath = await window.electron.getThemeSoundPath(activeTheme.id);
|
||||
if (soundPath) {
|
||||
@@ -137,7 +138,7 @@ export const getAchievementSoundUrl = async (): Promise<string> => {
|
||||
} catch (error) {
|
||||
console.error("Failed to get theme sound", error);
|
||||
}
|
||||
|
||||
|
||||
return defaultSound;
|
||||
};
|
||||
|
||||
|
||||
@@ -4,7 +4,12 @@ import {
|
||||
AchievementCustomNotificationPosition,
|
||||
AchievementNotificationInfo,
|
||||
} from "@types";
|
||||
import { injectCustomCss, removeCustomCss, getAchievementSoundUrl, getAchievementSoundVolume } from "@renderer/helpers";
|
||||
import {
|
||||
injectCustomCss,
|
||||
removeCustomCss,
|
||||
getAchievementSoundUrl,
|
||||
getAchievementSoundVolume,
|
||||
} from "@renderer/helpers";
|
||||
import { AchievementNotificationItem } from "@renderer/components/achievements/notification/achievement-notification";
|
||||
import app from "../../../app.scss?inline";
|
||||
import styles from "../../../components/achievements/notification/achievement-notification.scss?inline";
|
||||
|
||||
@@ -1,4 +1,11 @@
|
||||
import { useContext, useEffect, useMemo, useState, useCallback, useRef } from "react";
|
||||
import {
|
||||
useContext,
|
||||
useEffect,
|
||||
useMemo,
|
||||
useState,
|
||||
useCallback,
|
||||
useRef,
|
||||
} from "react";
|
||||
import {
|
||||
TextField,
|
||||
Button,
|
||||
@@ -51,7 +58,7 @@ export function SettingsGeneral() {
|
||||
const [languageOptions, setLanguageOptions] = useState<LanguageOption[]>([]);
|
||||
|
||||
const [defaultDownloadsPath, setDefaultDownloadsPath] = useState("");
|
||||
|
||||
|
||||
const volumeUpdateTimeoutRef = useRef<NodeJS.Timeout>();
|
||||
|
||||
useEffect(() => {
|
||||
@@ -116,7 +123,9 @@ export function SettingsGeneral() {
|
||||
userPreferences.achievementCustomNotificationsEnabled ?? true,
|
||||
achievementCustomNotificationPosition:
|
||||
userPreferences.achievementCustomNotificationPosition ?? "top-left",
|
||||
achievementSoundVolume: Math.round((userPreferences.achievementSoundVolume ?? 0.15) * 100),
|
||||
achievementSoundVolume: Math.round(
|
||||
(userPreferences.achievementSoundVolume ?? 0.15) * 100
|
||||
),
|
||||
friendRequestNotificationsEnabled:
|
||||
userPreferences.friendRequestNotificationsEnabled ?? false,
|
||||
friendStartGameNotificationsEnabled:
|
||||
@@ -155,17 +164,20 @@ export function SettingsGeneral() {
|
||||
await updateUserPreferences(values);
|
||||
};
|
||||
|
||||
const handleVolumeChange = useCallback((newVolume: number) => {
|
||||
setForm((prev) => ({ ...prev, achievementSoundVolume: newVolume }));
|
||||
|
||||
if (volumeUpdateTimeoutRef.current) {
|
||||
clearTimeout(volumeUpdateTimeoutRef.current);
|
||||
}
|
||||
|
||||
volumeUpdateTimeoutRef.current = setTimeout(() => {
|
||||
updateUserPreferences({ achievementSoundVolume: newVolume / 100 });
|
||||
}, 300);
|
||||
}, [updateUserPreferences]);
|
||||
const handleVolumeChange = useCallback(
|
||||
(newVolume: number) => {
|
||||
setForm((prev) => ({ ...prev, achievementSoundVolume: newVolume }));
|
||||
|
||||
if (volumeUpdateTimeoutRef.current) {
|
||||
clearTimeout(volumeUpdateTimeoutRef.current);
|
||||
}
|
||||
|
||||
volumeUpdateTimeoutRef.current = setTimeout(() => {
|
||||
updateUserPreferences({ achievementSoundVolume: newVolume / 100 });
|
||||
}, 300);
|
||||
},
|
||||
[updateUserPreferences]
|
||||
);
|
||||
|
||||
const handleChangeAchievementCustomNotificationPosition = async (
|
||||
event: React.ChangeEvent<HTMLSelectElement>
|
||||
@@ -347,13 +359,19 @@ export function SettingsGeneral() {
|
||||
handleVolumeChange(0);
|
||||
return;
|
||||
}
|
||||
const volumePercent = Math.min(100, Math.max(0, parseInt(value, 10)));
|
||||
const volumePercent = Math.min(
|
||||
100,
|
||||
Math.max(0, parseInt(value, 10))
|
||||
);
|
||||
if (!isNaN(volumePercent)) {
|
||||
handleVolumeChange(volumePercent);
|
||||
}
|
||||
}}
|
||||
onBlur={(e) => {
|
||||
if (e.target.value === "" || isNaN(parseInt(e.target.value, 10))) {
|
||||
if (
|
||||
e.target.value === "" ||
|
||||
isNaN(parseInt(e.target.value, 10))
|
||||
) {
|
||||
handleVolumeChange(0);
|
||||
}
|
||||
}}
|
||||
@@ -365,11 +383,19 @@ export function SettingsGeneral() {
|
||||
type="button"
|
||||
onClick={(e) => {
|
||||
e.preventDefault();
|
||||
const newVolume = Math.min(100, form.achievementSoundVolume + 1);
|
||||
const newVolume = Math.min(
|
||||
100,
|
||||
form.achievementSoundVolume + 1
|
||||
);
|
||||
handleVolumeChange(newVolume);
|
||||
}}
|
||||
>
|
||||
<svg width="12" height="12" viewBox="0 0 12 12" fill="currentColor">
|
||||
<svg
|
||||
width="12"
|
||||
height="12"
|
||||
viewBox="0 0 12 12"
|
||||
fill="currentColor"
|
||||
>
|
||||
<path d="M6 4l4 4H2l4-4z" />
|
||||
</svg>
|
||||
</button>
|
||||
@@ -377,11 +403,19 @@ export function SettingsGeneral() {
|
||||
type="button"
|
||||
onClick={(e) => {
|
||||
e.preventDefault();
|
||||
const newVolume = Math.max(0, form.achievementSoundVolume - 1);
|
||||
const newVolume = Math.max(
|
||||
0,
|
||||
form.achievementSoundVolume - 1
|
||||
);
|
||||
handleVolumeChange(newVolume);
|
||||
}}
|
||||
>
|
||||
<svg width="12" height="12" viewBox="0 0 12 12" fill="currentColor">
|
||||
<svg
|
||||
width="12"
|
||||
height="12"
|
||||
viewBox="0 0 12 12"
|
||||
fill="currentColor"
|
||||
>
|
||||
<path d="M6 8L2 4h8L6 8z" />
|
||||
</svg>
|
||||
</button>
|
||||
|
||||
@@ -4,10 +4,19 @@ import Editor from "@monaco-editor/react";
|
||||
import { AchievementCustomNotificationPosition, Theme } from "@types";
|
||||
import { useSearchParams } from "react-router-dom";
|
||||
import { Button, SelectField } from "@renderer/components";
|
||||
import { CheckIcon, UploadIcon, TrashIcon, PlayIcon } from "@primer/octicons-react";
|
||||
import {
|
||||
CheckIcon,
|
||||
UploadIcon,
|
||||
TrashIcon,
|
||||
PlayIcon,
|
||||
} from "@primer/octicons-react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import cn from "classnames";
|
||||
import { injectCustomCss, getAchievementSoundUrl, getAchievementSoundVolume } from "@renderer/helpers";
|
||||
import {
|
||||
injectCustomCss,
|
||||
getAchievementSoundUrl,
|
||||
getAchievementSoundVolume,
|
||||
} from "@renderer/helpers";
|
||||
import { AchievementNotificationItem } from "@renderer/components/achievements/notification/achievement-notification";
|
||||
import { generateAchievementCustomNotificationTest } from "@shared";
|
||||
import { CollapsedMenu } from "@renderer/components/collapsed-menu/collapsed-menu";
|
||||
|
||||
Reference in New Issue
Block a user