diff --git a/src/locales/en/translation.json b/src/locales/en/translation.json index 8b3893b3..25c660db 100644 --- a/src/locales/en/translation.json +++ b/src/locales/en/translation.json @@ -355,7 +355,8 @@ "common_redist_description": "Common redistributables are required to run some games. Installing them is recommended to avoid issues.", "install_common_redist": "Install", "installing_common_redist": "Installing…", - "show_download_speed_in_megabytes": "Show download speed in megabytes per second" + "show_download_speed_in_megabytes": "Show download speed in megabytes per second", + "extract_files_by_default": "Extract files by default after download" }, "notifications": { "download_complete": "Download complete", diff --git a/src/locales/pt-BR/translation.json b/src/locales/pt-BR/translation.json index 41c58ebf..4baff652 100644 --- a/src/locales/pt-BR/translation.json +++ b/src/locales/pt-BR/translation.json @@ -342,7 +342,8 @@ "common_redist_description": "Componentes recomendados são necessários para executar alguns jogos. A instalação deles é recomendada para evitar problemas.", "install_common_redist": "Instalar", "installing_common_redist": "Instalando…", - "show_download_speed_in_megabytes": "Exibir taxas de download em megabytes por segundo" + "show_download_speed_in_megabytes": "Exibir taxas de download em megabytes por segundo", + "extract_files_by_default": "Extrair arquivos automaticamente após o download" }, "notifications": { "download_complete": "Download concluído", diff --git a/src/renderer/src/pages/game-details/modals/download-settings-modal.tsx b/src/renderer/src/pages/game-details/modals/download-settings-modal.tsx index c06f280b..6bbbc09f 100644 --- a/src/renderer/src/pages/game-details/modals/download-settings-modal.tsx +++ b/src/renderer/src/pages/game-details/modals/download-settings-modal.tsx @@ -34,13 +34,26 @@ export function DownloadSettingsModal({ }: Readonly) { const { t } = useTranslation("game_details"); + const userPreferences = useAppSelector( + (state) => state.userPreferences.value + ); + + const getAutomaticExtractionValue = useCallback(() => { + if (userPreferences?.extractFilesByDefault === undefined) { + window.electron.updateUserPreferences({ extractFilesByDefault: true }); + } + + return userPreferences?.extractFilesByDefault ?? true; + }, [userPreferences?.extractFilesByDefault]); + const { showErrorToast } = useToast(); const [diskFreeSpace, setDiskFreeSpace] = useState(null); const [selectedPath, setSelectedPath] = useState(""); const [downloadStarting, setDownloadStarting] = useState(false); - const [automaticExtractionEnabled, setAutomaticExtractionEnabled] = - useState(true); + const [automaticExtractionEnabled, setAutomaticExtractionEnabled] = useState( + getAutomaticExtractionValue() + ); const [selectedDownloader, setSelectedDownloader] = useState(null); const [hasWritePermission, setHasWritePermission] = useState( @@ -49,10 +62,6 @@ export function DownloadSettingsModal({ const { isFeatureEnabled, Feature } = useFeature(); - const userPreferences = useAppSelector( - (state) => state.userPreferences.value - ); - const getDiskFreeSpace = async (path: string) => { const result = await window.electron.getDiskFreeSpace(path); setDiskFreeSpace(result.free); diff --git a/src/renderer/src/pages/settings/settings-behavior.tsx b/src/renderer/src/pages/settings/settings-behavior.tsx index 0afbf5b6..b21b6025 100644 --- a/src/renderer/src/pages/settings/settings-behavior.tsx +++ b/src/renderer/src/pages/settings/settings-behavior.tsx @@ -24,6 +24,7 @@ export function SettingsBehavior() { seedAfterDownloadComplete: false, showHiddenAchievementsDescription: false, showDownloadSpeedInMegabytes: false, + extractFilesByDefault: false, }); const { t } = useTranslation("settings"); @@ -43,6 +44,7 @@ export function SettingsBehavior() { userPreferences.showHiddenAchievementsDescription ?? false, showDownloadSpeedInMegabytes: userPreferences.showDownloadSpeedInMegabytes ?? false, + extractFilesByDefault: userPreferences.extractFilesByDefault ?? false, }); } }, [userPreferences]); @@ -152,6 +154,16 @@ export function SettingsBehavior() { }) } /> + + + handleChange({ + extractFilesByDefault: !form.extractFilesByDefault, + }) + } + /> ); } diff --git a/src/types/level.types.ts b/src/types/level.types.ts index f17abbd9..764998af 100644 --- a/src/types/level.types.ts +++ b/src/types/level.types.ts @@ -88,6 +88,7 @@ export interface UserPreferences { achievementNotificationsEnabled?: boolean; friendRequestNotificationsEnabled?: boolean; showDownloadSpeedInMegabytes?: boolean; + extractFilesByDefault?: boolean; } export interface ScreenState {