diff --git a/src/locales/en/translation.json b/src/locales/en/translation.json index 93e18f17..af371fb7 100644 --- a/src/locales/en/translation.json +++ b/src/locales/en/translation.json @@ -379,7 +379,8 @@ "platinum": "Platinum", "hidden": "Hidden", "test_notification": "Test notification", - "notification_preview": "Achievement Notification Preview" + "notification_preview": "Achievement Notification Preview", + "enable_friend_start_game_notifications": "When a friend starts play a game" }, "notifications": { "download_complete": "Download complete", diff --git a/src/locales/pt-BR/translation.json b/src/locales/pt-BR/translation.json index c99fab6f..6b9546ec 100644 --- a/src/locales/pt-BR/translation.json +++ b/src/locales/pt-BR/translation.json @@ -365,7 +365,8 @@ "platinum": "Platina", "hidden": "Oculta", "test_notification": "Testar notificação", - "notification_preview": "Prévia da Notificação de Conquistas" + "notification_preview": "Prévia da Notificação de Conquistas", + "enable_friend_start_game_notifications": "Quando um amigo iniciar um jogo" }, "notifications": { "download_complete": "Download concluído", diff --git a/src/main/events/library/open-game-installer-path.ts b/src/main/events/library/open-game-installer-path.ts index b61246fa..0bbe96de 100644 --- a/src/main/events/library/open-game-installer-path.ts +++ b/src/main/events/library/open-game-installer-path.ts @@ -12,16 +12,14 @@ const openGameInstallerPath = async ( ) => { const download = await downloadsSublevel.get(levelKeys.game(shop, objectId)); - if (!download || !download.folderName || !download.downloadPath) return true; + if (!download?.folderName || !download.downloadPath) return; const gamePath = path.join( download.downloadPath ?? (await getDownloadsPath()), - download.folderName! + download.folderName ); shell.showItemInFolder(gamePath); - - return true; }; registerEvent("openGameInstallerPath", openGameInstallerPath); diff --git a/src/main/services/ws/events/friend-game-session.ts b/src/main/services/ws/events/friend-game-session.ts index 930b4885..47d8164e 100644 --- a/src/main/services/ws/events/friend-game-session.ts +++ b/src/main/services/ws/events/friend-game-session.ts @@ -1,15 +1,25 @@ import type { FriendGameSession } from "@main/generated/envelope"; +import { db, levelKeys } from "@main/level"; import { HydraApi } from "@main/services/hydra-api"; import { publishFriendStartedPlayingGameNotification } from "@main/services/notifications"; -import { GameStats } from "@types"; +import type { GameStats, UserPreferences, UserProfile } from "@types"; export const friendGameSessionEvent = async (payload: FriendGameSession) => { + const userPreferences = await db.get( + levelKeys.userPreferences, + { + valueEncoding: "json", + } + ); + + if (userPreferences?.friendStartGameNotificationsEnabled === false) return; + const [friend, gameStats] = await Promise.all([ - HydraApi.get(`/users/${payload.friendId}`), + HydraApi.get(`/users/${payload.friendId}`), HydraApi.get( `/games/stats?objectId=${payload.objectId}&shop=steam` ), - ]); + ]).catch(() => [null, null]); if (friend && gameStats) { publishFriendStartedPlayingGameNotification(friend, gameStats); diff --git a/src/renderer/src/components/achievements/notification/achievement-notification.tsx b/src/renderer/src/components/achievements/notification/achievement-notification.tsx index 7bb681fe..bcc22047 100644 --- a/src/renderer/src/components/achievements/notification/achievement-notification.tsx +++ b/src/renderer/src/components/achievements/notification/achievement-notification.tsx @@ -31,7 +31,7 @@ export function AchievementNotificationItem({ [`${baseClassName}--platinum`]: achievement.isPlatinum, })} > - {achievement.points && ( + {achievement.points !== undefined && (
diff --git a/src/renderer/src/declaration.d.ts b/src/renderer/src/declaration.d.ts index 3290d798..05d0cad0 100644 --- a/src/renderer/src/declaration.d.ts +++ b/src/renderer/src/declaration.d.ts @@ -139,10 +139,7 @@ declare global { verifyExecutablePathInUse: (executablePath: string) => Promise; getLibrary: () => Promise; openGameInstaller: (shop: GameShop, objectId: string) => Promise; - openGameInstallerPath: ( - shop: GameShop, - objectId: string - ) => Promise; + openGameInstallerPath: (shop: GameShop, objectId: string) => Promise; openGameExecutablePath: (shop: GameShop, objectId: string) => Promise; openGame: ( shop: GameShop, diff --git a/src/renderer/src/pages/settings/settings-general.tsx b/src/renderer/src/pages/settings/settings-general.tsx index ad4f1b82..c698440d 100644 --- a/src/renderer/src/pages/settings/settings-general.tsx +++ b/src/renderer/src/pages/settings/settings-general.tsx @@ -38,6 +38,7 @@ export function SettingsGeneral() { downloadNotificationsEnabled: false, repackUpdatesNotificationsEnabled: false, friendRequestNotificationsEnabled: false, + friendStartGameNotificationsEnabled: true, achievementNotificationsEnabled: true, achievementCustomNotificationsEnabled: true, achievementCustomNotificationPosition: @@ -111,6 +112,8 @@ export function SettingsGeneral() { userPreferences.achievementCustomNotificationPosition ?? "top-left", friendRequestNotificationsEnabled: userPreferences.friendRequestNotificationsEnabled ?? false, + friendStartGameNotificationsEnabled: + userPreferences.friendStartGameNotificationsEnabled ?? true, language: language ?? "en", })); } @@ -248,6 +251,17 @@ export function SettingsGeneral() { } /> + + handleChange({ + friendStartGameNotificationsEnabled: + !form.friendStartGameNotificationsEnabled, + }) + } + /> +