feat: add option to disable friend starting game notification

This commit is contained in:
Zamitto
2025-05-19 07:23:46 -03:00
parent 73de69b5a6
commit e85d08422e
8 changed files with 36 additions and 14 deletions

View File

@@ -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);

View File

@@ -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<string, UserPreferences | null>(
levelKeys.userPreferences,
{
valueEncoding: "json",
}
);
if (userPreferences?.friendStartGameNotificationsEnabled === false) return;
const [friend, gameStats] = await Promise.all([
HydraApi.get(`/users/${payload.friendId}`),
HydraApi.get<UserProfile>(`/users/${payload.friendId}`),
HydraApi.get<GameStats>(
`/games/stats?objectId=${payload.objectId}&shop=steam`
),
]);
]).catch(() => [null, null]);
if (friend && gameStats) {
publishFriendStartedPlayingGameNotification(friend, gameStats);