Merge branch 'main' into feat/use-native-notification-for-achievements

# Conflicts:
#	src/main/index.ts
This commit is contained in:
Zamitto 2024-10-31 12:53:39 -03:00
commit 9ee4e2e29b
12 changed files with 72 additions and 16 deletions

View file

@ -35,6 +35,9 @@ export class UserPreferences {
@Column("boolean", { default: false })
runAtStartup: boolean;
@Column("boolean", { default: false })
startMinimized: boolean;
@CreateDateColumn()
createdAt: Date;

View file

@ -16,15 +16,16 @@ const windowsStartupPath = path.join(
const autoLaunch = async (
_event: Electron.IpcMainInvokeEvent,
enabled: boolean
autoLaunchProps: { enabled: boolean; minimized: boolean }
) => {
if (!app.isPackaged) return;
const appLauncher = new AutoLaunch({
name: app.getName(),
isHidden: autoLaunchProps.minimized,
});
if (enabled) {
if (autoLaunchProps.enabled) {
appLauncher.enable().catch((err) => {
logger.error(err);
});

View file

@ -101,7 +101,10 @@ app.whenReady().then(async () => {
i18n.changeLanguage(userPreferences.language);
}
WindowManager.createMainWindow();
if (!process.argv.includes("--hidden")) {
WindowManager.createMainWindow();
}
WindowManager.createSystemTray(userPreferences?.language || "en");
});

View file

@ -11,7 +11,7 @@ import { AddAchievementNotificationPreference } from "./migrations/2024101301290
import { CreateUserSubscription } from "./migrations/20241015235142_create_user_subscription";
import { AddBackgroundImageUrl } from "./migrations/20241016100249_add_background_image_url";
import { AddWinePrefixToGame } from "./migrations/20241019081648_add_wine_prefix_to_game";
import { AddStartMinimizedColumn } from "./migrations/20241030171454_add_start_minimized_column";
export type HydraMigration = Knex.Migration & { name: string };
class MigrationSource implements Knex.MigrationSource<HydraMigration> {
@ -27,6 +27,7 @@ class MigrationSource implements Knex.MigrationSource<HydraMigration> {
CreateUserSubscription,
AddBackgroundImageUrl,
AddWinePrefixToGame,
AddStartMinimizedColumn,
]);
}
getMigrationName(migration: HydraMigration): string {

View file

@ -0,0 +1,17 @@
import type { HydraMigration } from "@main/knex-client";
import type { Knex } from "knex";
export const AddStartMinimizedColumn: HydraMigration = {
name: "AddStartMinimizedColumn",
up: (knex: Knex) => {
return knex.schema.alterTable("user_preferences", (table) => {
return table.boolean("startMinimized").notNullable().defaultTo(0);
});
},
down: async (knex: Knex) => {
return knex.schema.alterTable("user_preferences", (table) => {
return table.dropColumn("startMinimized");
});
},
};

View file

@ -268,14 +268,15 @@ export class WindowManager {
if (process.platform !== "darwin") {
tray.addListener("click", () => {
if (this.mainWindow) {
if (WindowManager.mainWindow?.isMinimized())
WindowManager.mainWindow.restore();
WindowManager.mainWindow?.focus();
return;
if (
WindowManager.mainWindow?.isMinimized() ||
!WindowManager.mainWindow?.isVisible()
) {
WindowManager.mainWindow?.show();
}
} else {
this.createMainWindow();
}
this.createMainWindow();
});
tray.addListener("right-click", showContextMenu);