diff --git a/src/locales/en/translation.json b/src/locales/en/translation.json index 0ee177c2..db9e1a72 100644 --- a/src/locales/en/translation.json +++ b/src/locales/en/translation.json @@ -365,12 +365,12 @@ "show_download_speed_in_megabytes": "Show download speed in megabytes per second", "extract_files_by_default": "Extract files by default after download", "achievement_custom_notification_position": "Achievement custom notification position", - "top_left": "Top left", - "top_center": "Top center", - "top_right": "Top right", - "bottom_left": "Bottom left", - "bottom_center": "Bottom center", - "bottom_right": "Bottom right", + "top-left": "Top left", + "top-center": "Top center", + "top-right": "Top right", + "bottom-left": "Bottom left", + "bottom-center": "Bottom center", + "bottom-right": "Bottom right", "enable_achievement_custom_notifications": "Enable achievement custom notifications", "alignment": "Alignment", "variation": "Variation", diff --git a/src/locales/pt-BR/translation.json b/src/locales/pt-BR/translation.json index a678a472..7d95ee0e 100644 --- a/src/locales/pt-BR/translation.json +++ b/src/locales/pt-BR/translation.json @@ -351,12 +351,12 @@ "show_download_speed_in_megabytes": "Exibir taxas de download em megabytes por segundo", "extract_files_by_default": "Extrair arquivos automaticamente após o download", "enable_achievement_custom_notifications": "Habilitar notificações customizadas de conquistas", - "top_left": "Superior esquerdo", - "top_center": "Superior central", - "top_right": "Superior direito", - "bottom_left": "Inferior esquerdo", - "bottom_right": "Inferior direito", - "bottom_center": "Inferior central", + "top-left": "Superior esquerdo", + "top-center": "Superior central", + "top-right": "Superior direito", + "bottom-left": "Inferior esquerdo", + "bottom-right": "Inferior direito", + "bottom-center": "Inferior central", "achievement_custom_notification_position": "Posição das notificações customizadas de conquista", "alignment": "Alinhamento", "variation": "Variação", diff --git a/src/main/events/index.ts b/src/main/events/index.ts index d937e3c4..d0f900d9 100644 --- a/src/main/events/index.ts +++ b/src/main/events/index.ts @@ -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"; diff --git a/src/main/events/notifications/show-achievement-test-notification.ts b/src/main/events/notifications/show-achievement-test-notification.ts new file mode 100644 index 00000000..b6f425f3 --- /dev/null +++ b/src/main/events/notifications/show-achievement-test-notification.ts @@ -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 +); diff --git a/src/main/events/notifications/update-achievement-notification-window.ts b/src/main/events/notifications/update-achievement-notification-window.ts index 93a2feb7..48fba272 100644 --- a/src/main/events/notifications/update-achievement-notification-window.ts +++ b/src/main/events/notifications/update-achievement-notification-window.ts @@ -19,7 +19,7 @@ const updateAchievementCustomNotificationWindow = async ( userPreferences.achievementNotificationsEnabled && userPreferences.achievementCustomNotificationsEnabled !== false ) { - WindowManager.createNotificationWindow(true); + WindowManager.createNotificationWindow(); } }; diff --git a/src/main/services/window-manager.ts b/src/main/services/window-manager.ts index 647db95b..0c58c867 100644 --- a/src/main/services/window-manager.ts +++ b/src/main/services/window-manager.ts @@ -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( 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( 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)] ); } diff --git a/src/preload/index.ts b/src/preload/index.ts index c80f60ba..482b9d19 100644 --- a/src/preload/index.ts +++ b/src/preload/index.ts @@ -442,6 +442,8 @@ contextBridge.exposeInMainWorld("electron", { }, updateAchievementCustomNotificationWindow: () => ipcRenderer.invoke("updateAchievementCustomNotificationWindow"), + showAchievementTestNotification: () => + ipcRenderer.invoke("showAchievementTestNotification"), /* Themes */ addCustomTheme: (theme: Theme) => ipcRenderer.invoke("addCustomTheme", theme), diff --git a/src/renderer/src/declaration.d.ts b/src/renderer/src/declaration.d.ts index 5cdd8c04..cc7261e1 100644 --- a/src/renderer/src/declaration.d.ts +++ b/src/renderer/src/declaration.d.ts @@ -338,6 +338,7 @@ declare global { ) => void ) => () => Electron.IpcRenderer; updateAchievementCustomNotificationWindow: () => Promise; + showAchievementTestNotification: () => Promise; /* Themes */ addCustomTheme: (theme: Theme) => Promise; diff --git a/src/renderer/src/pages/settings/settings-general.tsx b/src/renderer/src/pages/settings/settings-general.tsx index 11bbf476..96a69fd0 100644 --- a/src/renderer/src/pages/settings/settings-general.tsx +++ b/src/renderer/src/pages/settings/settings-general.tsx @@ -288,9 +288,7 @@ export function SettingsGeneral() {