mirror of
https://github.com/hydralauncher/hydra.git
synced 2026-01-27 04:41:03 +00:00
feat: refactor test notiication event
This commit is contained in:
@@ -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";
|
||||
|
||||
@@ -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
|
||||
);
|
||||
@@ -19,7 +19,7 @@ const updateAchievementCustomNotificationWindow = async (
|
||||
userPreferences.achievementNotificationsEnabled &&
|
||||
userPreferences.achievementCustomNotificationsEnabled !== false
|
||||
) {
|
||||
WindowManager.createNotificationWindow(true);
|
||||
WindowManager.createNotificationWindow();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -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)]
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user