mirror of
https://github.com/hydralauncher/hydra.git
synced 2026-01-25 20:01:03 +00:00
feat: separate game assets from game stats
This commit is contained in:
@@ -58,7 +58,11 @@ export const mergeWithRemoteGames = async () => {
|
||||
});
|
||||
}
|
||||
|
||||
const localGameShopAsset = await gamesShopAssetsSublevel.get(gameKey);
|
||||
|
||||
await gamesShopAssetsSublevel.put(gameKey, {
|
||||
updatedAt: Date.now(),
|
||||
...localGameShopAsset,
|
||||
shop: game.shop,
|
||||
objectId: game.objectId,
|
||||
title: localGame?.title || game.title, // Preserve local title if it exists
|
||||
|
||||
@@ -10,7 +10,7 @@ import icon from "@resources/icon.png?asset";
|
||||
import { NotificationOptions, toXmlString } from "./xml";
|
||||
import { logger } from "../logger";
|
||||
import { WindowManager } from "../window-manager";
|
||||
import type { Game, GameStats, UserPreferences, UserProfile } from "@types";
|
||||
import type { Game, UserPreferences, UserProfile } from "@types";
|
||||
import { db, levelKeys } from "@main/level";
|
||||
import { restartAndInstallUpdate } from "@main/events/autoupdater/restart-and-install-update";
|
||||
import { SystemPath } from "../system-path";
|
||||
@@ -108,15 +108,14 @@ export const publishNewFriendRequestNotification = async (
|
||||
};
|
||||
|
||||
export const publishFriendStartedPlayingGameNotification = async (
|
||||
friend: UserProfile,
|
||||
game: GameStats
|
||||
friend: UserProfile
|
||||
) => {
|
||||
new Notification({
|
||||
title: t("friend_started_playing_game", {
|
||||
ns: "notifications",
|
||||
displayName: friend.displayName,
|
||||
}),
|
||||
body: game.assets?.title,
|
||||
body: friend?.currentGame?.title,
|
||||
icon: friend?.profileImageUrl
|
||||
? await downloadImage(friend.profileImageUrl)
|
||||
: trayIcon,
|
||||
|
||||
@@ -2,7 +2,7 @@ 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 type { GameStats, UserPreferences, UserProfile } from "@types";
|
||||
import type { UserPreferences, UserProfile } from "@types";
|
||||
|
||||
export const friendGameSessionEvent = async (payload: FriendGameSession) => {
|
||||
const userPreferences = await db.get<string, UserPreferences | null>(
|
||||
@@ -14,12 +14,9 @@ export const friendGameSessionEvent = async (payload: FriendGameSession) => {
|
||||
|
||||
if (userPreferences?.friendStartGameNotificationsEnabled === false) return;
|
||||
|
||||
const [friend, gameStats] = await Promise.all([
|
||||
HydraApi.get<UserProfile>(`/users/${payload.friendId}`),
|
||||
HydraApi.get<GameStats>(`/games/steam/${payload.objectId}/stats`),
|
||||
]).catch(() => [null, null]);
|
||||
const friend = await HydraApi.get<UserProfile>(`/users/${payload.friendId}`);
|
||||
|
||||
if (friend && gameStats) {
|
||||
publishFriendStartedPlayingGameNotification(friend, gameStats);
|
||||
if (friend) {
|
||||
publishFriendStartedPlayingGameNotification(friend);
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user