refactor ternary to if statement in window-manager, update constant definitions for better clarity

This commit is contained in:
Hachi-R 2024-05-03 14:58:45 -03:00
parent 94b7c8aefe
commit 315d03ae69
6 changed files with 18 additions and 12 deletions

View File

@ -136,7 +136,7 @@
"telemetry": "Telemetry",
"telemetry_description": "Enable anonymous usage statistics",
"behavior": "Behavior",
"quit_app_instead_minimizing": "Close app instead of minimizing to tray"
"quit_app_instead_hiding": "Close app instead of minimizing to tray"
},
"notifications": {
"download_complete": "Download complete",

View File

@ -132,7 +132,7 @@
"telemetry": "Telemetria",
"telemetry_description": "Habilitar estatísticas de uso anônimas",
"behavior": "Comportamento",
"quit_app_instead_minimizing": "Fechar o aplicativo em vez de minimizá-lo"
"quit_app_instead_hiding": "Fechar o aplicativo em vez de minimizá-lo"
},
"notifications": {
"download_complete": "Download concluído",

View File

@ -27,7 +27,7 @@ export class UserPreferences {
telemetryEnabled: boolean;
@Column("boolean", { default: false })
quitInXButtonEnabled: boolean;
preferQuitInsteadOfHiding: boolean;
@CreateDateColumn()
createdAt: Date;

View File

@ -51,11 +51,14 @@ export class WindowManager {
this.mainWindow.removeMenu();
const userPreferences = await userPreferencesRepository.findOne({
where: {id: 1},
where: { id: 1 },
});
this.mainWindow.on("close", () => {
userPreferences?.quitInXButtonEnabled ? app.quit() : WindowManager.mainWindow?.setProgressBar(-1);
if (userPreferences?.preferQuitInsteadOfHiding) {
app.quit();
}
WindowManager.mainWindow?.setProgressBar(-1);
});
}

View File

@ -11,7 +11,7 @@ export function Settings() {
downloadNotificationsEnabled: false,
repackUpdatesNotificationsEnabled: false,
telemetryEnabled: false,
quitInXButtonEnabled: false,
preferQuitInsteadOfHiding: false,
});
const { t } = useTranslation("settings");
@ -28,7 +28,8 @@ export function Settings() {
repackUpdatesNotificationsEnabled:
userPreferences?.repackUpdatesNotificationsEnabled ?? false,
telemetryEnabled: userPreferences?.telemetryEnabled ?? false,
quitInXButtonEnabled: userPreferences?.quitInXButtonEnabled ?? false,
preferQuitInsteadOfHiding:
userPreferences?.preferQuitInsteadOfHiding ?? false,
});
});
}, []);
@ -113,13 +114,15 @@ export function Settings() {
<h3>{t("behavior")}</h3>
<CheckboxField
label={t("quit_app_instead_minimizing")}
checked={form.quitInXButtonEnabled}
label={t("quit_app_instead_hiding")}
checked={form.preferQuitInsteadOfHiding}
onChange={() =>
updateUserPreferences("quitInXButtonEnabled", !form.quitInXButtonEnabled)
updateUserPreferences(
"preferQuitInsteadOfHiding",
!form.preferQuitInsteadOfHiding
)
}
/>
</div>
</section>
);

View File

@ -105,7 +105,7 @@ export interface UserPreferences {
downloadNotificationsEnabled: boolean;
repackUpdatesNotificationsEnabled: boolean;
telemetryEnabled: boolean;
quitInXButtonEnabled: boolean;
preferQuitInsteadOfHiding: boolean;
}
export interface HowLongToBeatCategory {