feat: refactor test notiication event

This commit is contained in:
Zamitto
2025-05-17 19:06:01 -03:00
parent 914942d328
commit ee916b998a
9 changed files with 38 additions and 27 deletions

View File

@@ -88,6 +88,7 @@ import "./cloud-save/delete-game-artifact";
import "./cloud-save/select-game-backup-path";
import "./notifications/publish-new-repacks-notification";
import "./notifications/update-achievement-notification-window";
import "./notifications/show-achievement-test-notification";
import "./themes/add-custom-theme";
import "./themes/delete-custom-theme";
import "./themes/get-all-custom-themes";

View File

@@ -0,0 +1,15 @@
import { registerEvent } from "../register-event";
import { WindowManager } from "@main/services";
const showAchievementTestNotification = async (
_event: Electron.IpcMainInvokeEvent
) => {
setTimeout(() => {
WindowManager.showAchievementTestNotification();
}, 1000);
};
registerEvent(
"showAchievementTestNotification",
showAchievementTestNotification
);

View File

@@ -19,7 +19,7 @@ const updateAchievementCustomNotificationWindow = async (
userPreferences.achievementNotificationsEnabled &&
userPreferences.achievementCustomNotificationsEnabled !== false
) {
WindowManager.createNotificationWindow(true);
WindowManager.createNotificationWindow();
}
};

View File

@@ -330,7 +330,9 @@ export class WindowManager {
};
}
public static async createNotificationWindow(showTestNotification = false) {
public static async createNotificationWindow() {
if (this.notificationWindow) return;
const userPreferences = await db.get<string, UserPreferences>(
levelKeys.userPreferences,
{
@@ -364,17 +366,9 @@ export class WindowManager {
// });
this.notificationWindow.setAlwaysOnTop(true, "screen-saver", 1);
this.loadNotificationWindowURL();
this.notificationWindow.once("ready-to-show", () => {
if (showTestNotification) {
setTimeout(() => {
this.showTestNotification();
}, 1000);
}
});
}
public static async showTestNotification() {
public static async showAchievementTestNotification() {
const userPreferences = await db.get<string, UserPreferences>(
levelKeys.userPreferences,
{
@@ -386,7 +380,7 @@ export class WindowManager {
this.notificationWindow?.webContents.send(
"on-achievement-unlocked",
userPreferences.achievementCustomNotificationPosition ?? "top_left",
userPreferences.achievementCustomNotificationPosition ?? "top-left",
[generateAchievementCustomNotificationTest(t, language)]
);
}