mirror of
https://github.com/hydralauncher/hydra.git
synced 2025-03-09 15:40:26 +00:00
feat: add property
This commit is contained in:
parent
c1bd1d30d7
commit
5101684154
2 changed files with 22 additions and 25 deletions
|
@ -1,7 +1,7 @@
|
||||||
import { registerEvent } from "../register-event";
|
import { registerEvent } from "../register-event";
|
||||||
import { HydraApi } from "@main/services";
|
import { HydraApi } from "@main/services";
|
||||||
import { steamGamesWorker } from "@main/workers";
|
import { steamGamesWorker } from "@main/workers";
|
||||||
import { UserProfile } from "@types";
|
import { UserGame, UserProfile } from "@types";
|
||||||
import { convertSteamGameToCatalogueEntry } from "../helpers/search-games";
|
import { convertSteamGameToCatalogueEntry } from "../helpers/search-games";
|
||||||
import { getSteamAppAsset } from "@main/helpers";
|
import { getSteamAppAsset } from "@main/helpers";
|
||||||
import { getUserFriends } from "./get-user-friends";
|
import { getUserFriends } from "./get-user-friends";
|
||||||
|
@ -20,35 +20,13 @@ const getUser = async (
|
||||||
|
|
||||||
const recentGames = await Promise.all(
|
const recentGames = await Promise.all(
|
||||||
profile.recentGames.map(async (game) => {
|
profile.recentGames.map(async (game) => {
|
||||||
const steamGame = await steamGamesWorker.run(Number(game.objectId), {
|
return getSteamUserGame(game);
|
||||||
name: "getById",
|
|
||||||
});
|
|
||||||
const iconUrl = steamGame?.clientIcon
|
|
||||||
? getSteamAppAsset("icon", game.objectId, steamGame.clientIcon)
|
|
||||||
: null;
|
|
||||||
|
|
||||||
return {
|
|
||||||
...game,
|
|
||||||
...convertSteamGameToCatalogueEntry(steamGame),
|
|
||||||
iconUrl,
|
|
||||||
};
|
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
const libraryGames = await Promise.all(
|
const libraryGames = await Promise.all(
|
||||||
profile.libraryGames.map(async (game) => {
|
profile.libraryGames.map(async (game) => {
|
||||||
const steamGame = await steamGamesWorker.run(Number(game.objectId), {
|
return getSteamUserGame(game);
|
||||||
name: "getById",
|
|
||||||
});
|
|
||||||
const iconUrl = steamGame?.clientIcon
|
|
||||||
? getSteamAppAsset("icon", game.objectId, steamGame.clientIcon)
|
|
||||||
: null;
|
|
||||||
|
|
||||||
return {
|
|
||||||
...game,
|
|
||||||
...convertSteamGameToCatalogueEntry(steamGame),
|
|
||||||
iconUrl,
|
|
||||||
};
|
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -58,10 +36,28 @@ const getUser = async (
|
||||||
recentGames,
|
recentGames,
|
||||||
friends: friends.friends,
|
friends: friends.friends,
|
||||||
totalFriends: friends.totalFriends,
|
totalFriends: friends.totalFriends,
|
||||||
|
currentGame: profile.currentGame
|
||||||
|
? getSteamUserGame(profile.currentGame)
|
||||||
|
: null,
|
||||||
};
|
};
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const getSteamUserGame = async (game): Promise<UserGame> => {
|
||||||
|
const steamGame = await steamGamesWorker.run(Number(game.objectId), {
|
||||||
|
name: "getById",
|
||||||
|
});
|
||||||
|
const iconUrl = steamGame?.clientIcon
|
||||||
|
? getSteamAppAsset("icon", game.objectId, steamGame.clientIcon)
|
||||||
|
: null;
|
||||||
|
|
||||||
|
return {
|
||||||
|
...game,
|
||||||
|
...convertSteamGameToCatalogueEntry(steamGame),
|
||||||
|
iconUrl,
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
registerEvent("getUser", getUser);
|
registerEvent("getUser", getUser);
|
||||||
|
|
|
@ -318,6 +318,7 @@ export interface UserProfile {
|
||||||
friends: UserFriend[];
|
friends: UserFriend[];
|
||||||
totalFriends: number;
|
totalFriends: number;
|
||||||
relation: UserRelation | null;
|
relation: UserRelation | null;
|
||||||
|
currentGame: UserGame | null;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface UpdateProfileProps {
|
export interface UpdateProfileProps {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue