mirror of
https://github.com/hydralauncher/hydra.git
synced 2026-01-11 13:56:16 +00:00
feat: checkbox to disable new game update badges
This commit is contained in:
@@ -544,6 +544,7 @@
|
||||
"show_download_speed_in_megabytes": "Show download speed in megabytes per second",
|
||||
"extract_files_by_default": "Extract files by default after download",
|
||||
"enable_steam_achievements": "Enable search for Steam achievements",
|
||||
"enable_new_download_options_badges": "Show new download options badges",
|
||||
"achievement_custom_notification_position": "Achievement custom notification position",
|
||||
"top-left": "Top left",
|
||||
"top-center": "Top center",
|
||||
|
||||
@@ -59,8 +59,8 @@ export const loadState = async () => {
|
||||
const { syncDownloadSourcesFromApi } = await import("./services/user");
|
||||
void syncDownloadSourcesFromApi();
|
||||
|
||||
// Check for new download options on startup
|
||||
DownloadSourcesChecker.checkForChanges();
|
||||
// Check for new download options on startup (if enabled)
|
||||
void DownloadSourcesChecker.checkForChanges();
|
||||
WSClient.connect();
|
||||
});
|
||||
|
||||
|
||||
@@ -5,10 +5,12 @@ import {
|
||||
updateDownloadSourcesCheckBaseline,
|
||||
updateDownloadSourcesSinceValue,
|
||||
downloadSourcesSublevel,
|
||||
db,
|
||||
levelKeys,
|
||||
} from "@main/level";
|
||||
import { logger } from "./logger";
|
||||
import { WindowManager } from "./window-manager";
|
||||
import type { Game } from "@types";
|
||||
import type { Game, UserPreferences } from "@types";
|
||||
|
||||
interface DownloadSourcesChangeResponse {
|
||||
shop: string;
|
||||
@@ -101,6 +103,20 @@ export class DownloadSourcesChecker {
|
||||
logger.info("DownloadSourcesChecker.checkForChanges() called");
|
||||
|
||||
try {
|
||||
const userPreferences = await db.get<string, UserPreferences | null>(
|
||||
levelKeys.userPreferences,
|
||||
{
|
||||
valueEncoding: "json",
|
||||
}
|
||||
);
|
||||
|
||||
if (userPreferences?.enableNewDownloadOptionsBadges === false) {
|
||||
logger.info(
|
||||
"New download options badges are disabled, skipping download sources check"
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
// Get all installed games (excluding custom games)
|
||||
const installedGames = await gamesSublevel.values().all();
|
||||
const nonCustomGames = installedGames.filter(
|
||||
|
||||
@@ -5,6 +5,7 @@ import cn from "classnames";
|
||||
import { useLocation } from "react-router-dom";
|
||||
import { useState } from "react";
|
||||
import { GameContextMenu } from "..";
|
||||
import { useAppSelector } from "@renderer/hooks";
|
||||
|
||||
interface SidebarGameItemProps {
|
||||
game: LibraryGame;
|
||||
@@ -18,6 +19,9 @@ export function SidebarGameItem({
|
||||
getGameTitle,
|
||||
}: Readonly<SidebarGameItemProps>) {
|
||||
const location = useLocation();
|
||||
const userPreferences = useAppSelector(
|
||||
(state) => state.userPreferences.value
|
||||
);
|
||||
const [contextMenu, setContextMenu] = useState<{
|
||||
visible: boolean;
|
||||
position: { x: number; y: number };
|
||||
@@ -81,11 +85,12 @@ export function SidebarGameItem({
|
||||
{getGameTitle(game)}
|
||||
</span>
|
||||
|
||||
{(game.newDownloadOptionsCount ?? 0) > 0 && (
|
||||
<span className="sidebar__game-badge">
|
||||
+{game.newDownloadOptionsCount}
|
||||
</span>
|
||||
)}
|
||||
{userPreferences?.enableNewDownloadOptionsBadges !== false &&
|
||||
(game.newDownloadOptionsCount ?? 0) > 0 && (
|
||||
<span className="sidebar__game-badge">
|
||||
+{game.newDownloadOptionsCount}
|
||||
</span>
|
||||
)}
|
||||
</button>
|
||||
</li>
|
||||
|
||||
|
||||
@@ -21,7 +21,12 @@ import { DownloadSettingsModal } from "./download-settings-modal";
|
||||
import { gameDetailsContext } from "@renderer/context";
|
||||
import { Downloader } from "@shared";
|
||||
import { orderBy } from "lodash-es";
|
||||
import { useDate, useFeature, useAppDispatch } from "@renderer/hooks";
|
||||
import {
|
||||
useDate,
|
||||
useFeature,
|
||||
useAppDispatch,
|
||||
useAppSelector,
|
||||
} from "@renderer/hooks";
|
||||
import { clearNewDownloadOptions } from "@renderer/features";
|
||||
import "./repacks-modal.scss";
|
||||
|
||||
@@ -68,6 +73,9 @@ export function RepacksModal({
|
||||
const { formatDate } = useDate();
|
||||
const navigate = useNavigate();
|
||||
const dispatch = useAppDispatch();
|
||||
const userPreferences = useAppSelector(
|
||||
(state) => state.userPreferences.value
|
||||
);
|
||||
|
||||
const getHashFromMagnet = (magnet: string) => {
|
||||
if (!magnet || typeof magnet !== "string") {
|
||||
@@ -115,10 +123,12 @@ export function RepacksModal({
|
||||
setIsLoadingTimestamp(false);
|
||||
};
|
||||
|
||||
if (visible) {
|
||||
if (visible && userPreferences?.enableNewDownloadOptionsBadges !== false) {
|
||||
fetchLastCheckTimestamp();
|
||||
} else {
|
||||
setIsLoadingTimestamp(false);
|
||||
}
|
||||
}, [visible, repacks]);
|
||||
}, [visible, repacks, userPreferences?.enableNewDownloadOptionsBadges]);
|
||||
|
||||
useEffect(() => {
|
||||
if (
|
||||
@@ -326,11 +336,13 @@ export function RepacksModal({
|
||||
>
|
||||
<p className="repacks-modal__repack-title">
|
||||
{repack.title}
|
||||
{isNewRepack(repack) && (
|
||||
<span className="repacks-modal__new-badge">
|
||||
{t("new_download_option")}
|
||||
</span>
|
||||
)}
|
||||
{userPreferences?.enableNewDownloadOptionsBadges !==
|
||||
false &&
|
||||
isNewRepack(repack) && (
|
||||
<span className="repacks-modal__new-badge">
|
||||
{t("new_download_option")}
|
||||
</span>
|
||||
)}
|
||||
</p>
|
||||
|
||||
{isLastDownloadedOption && (
|
||||
|
||||
@@ -29,6 +29,7 @@ export function SettingsBehavior() {
|
||||
enableSteamAchievements: false,
|
||||
autoplayGameTrailers: true,
|
||||
hideToTrayOnGameStart: false,
|
||||
enableNewDownloadOptionsBadges: true,
|
||||
});
|
||||
|
||||
const { t } = useTranslation("settings");
|
||||
@@ -53,6 +54,8 @@ export function SettingsBehavior() {
|
||||
userPreferences.enableSteamAchievements ?? false,
|
||||
autoplayGameTrailers: userPreferences.autoplayGameTrailers ?? true,
|
||||
hideToTrayOnGameStart: userPreferences.hideToTrayOnGameStart ?? false,
|
||||
enableNewDownloadOptionsBadges:
|
||||
userPreferences.enableNewDownloadOptionsBadges ?? true,
|
||||
});
|
||||
}
|
||||
}, [userPreferences]);
|
||||
@@ -209,6 +212,17 @@ export function SettingsBehavior() {
|
||||
<QuestionIcon size={12} />
|
||||
</small>
|
||||
</div>
|
||||
|
||||
<CheckboxField
|
||||
label={t("enable_new_download_options_badges")}
|
||||
checked={form.enableNewDownloadOptionsBadges}
|
||||
onChange={() =>
|
||||
handleChange({
|
||||
enableNewDownloadOptionsBadges:
|
||||
!form.enableNewDownloadOptionsBadges,
|
||||
})
|
||||
}
|
||||
/>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -124,6 +124,7 @@ export interface UserPreferences {
|
||||
enableSteamAchievements?: boolean;
|
||||
autoplayGameTrailers?: boolean;
|
||||
hideToTrayOnGameStart?: boolean;
|
||||
enableNewDownloadOptionsBadges?: boolean;
|
||||
}
|
||||
|
||||
export interface ScreenState {
|
||||
|
||||
Reference in New Issue
Block a user