mirror of
https://github.com/hydralauncher/hydra.git
synced 2026-01-26 20:31:03 +00:00
Compare commits
8 Commits
feat/setti
...
fix/custom
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ad588b5600 | ||
|
|
c24ad34bc7 | ||
|
|
4f2c3105ce | ||
|
|
feedcb1dc7 | ||
|
|
4b8d64c72b | ||
|
|
dff68a3e26 | ||
|
|
58bdbdab71 | ||
|
|
574a012d8c |
@@ -6,6 +6,10 @@ import { gamesShopAssetsSublevel, levelKeys } from "@main/level";
|
|||||||
const LOCAL_CACHE_EXPIRATION = 1000 * 60 * 60 * 8; // 8 hours
|
const LOCAL_CACHE_EXPIRATION = 1000 * 60 * 60 * 8; // 8 hours
|
||||||
|
|
||||||
export const getGameAssets = async (objectId: string, shop: GameShop) => {
|
export const getGameAssets = async (objectId: string, shop: GameShop) => {
|
||||||
|
if (shop === "custom") {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
const cachedAssets = await gamesShopAssetsSublevel.get(
|
const cachedAssets = await gamesShopAssetsSublevel.get(
|
||||||
levelKeys.game(shop, objectId)
|
levelKeys.game(shop, objectId)
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -26,6 +26,8 @@ const getGameShopDetails = async (
|
|||||||
shop: GameShop,
|
shop: GameShop,
|
||||||
language: string
|
language: string
|
||||||
): Promise<ShopDetailsWithAssets | null> => {
|
): Promise<ShopDetailsWithAssets | null> => {
|
||||||
|
if (shop === "custom") return null;
|
||||||
|
|
||||||
if (shop === "steam") {
|
if (shop === "steam") {
|
||||||
const [cachedData, cachedAssets] = await Promise.all([
|
const [cachedData, cachedAssets] = await Promise.all([
|
||||||
gamesShopCacheSublevel.get(
|
gamesShopCacheSublevel.get(
|
||||||
|
|||||||
@@ -10,6 +10,10 @@ const getGameStats = async (
|
|||||||
objectId: string,
|
objectId: string,
|
||||||
shop: GameShop
|
shop: GameShop
|
||||||
) => {
|
) => {
|
||||||
|
if (shop === "custom") {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
const cachedStats = await gamesStatsCacheSublevel.get(
|
const cachedStats = await gamesStatsCacheSublevel.get(
|
||||||
levelKeys.game(shop, objectId)
|
levelKeys.game(shop, objectId)
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -13,7 +13,9 @@ const addGameToFavorites = async (
|
|||||||
const game = await gamesSublevel.get(gameKey);
|
const game = await gamesSublevel.get(gameKey);
|
||||||
if (!game) return;
|
if (!game) return;
|
||||||
|
|
||||||
HydraApi.put(`/profile/games/${shop}/${objectId}/favorite`).catch(() => {});
|
if (shop !== "custom") {
|
||||||
|
HydraApi.put(`/profile/games/${shop}/${objectId}/favorite`).catch(() => {});
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await gamesSublevel.put(gameKey, {
|
await gamesSublevel.put(gameKey, {
|
||||||
|
|||||||
@@ -13,7 +13,11 @@ const removeGameFromFavorites = async (
|
|||||||
const game = await gamesSublevel.get(gameKey);
|
const game = await gamesSublevel.get(gameKey);
|
||||||
if (!game) return;
|
if (!game) return;
|
||||||
|
|
||||||
HydraApi.put(`/profile/games/${shop}/${objectId}/unfavorite`).catch(() => {});
|
if (shop !== "custom") {
|
||||||
|
HydraApi.put(`/profile/games/${shop}/${objectId}/unfavorite`).catch(
|
||||||
|
() => {}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await gamesSublevel.put(gameKey, {
|
await gamesSublevel.put(gameKey, {
|
||||||
|
|||||||
@@ -84,7 +84,7 @@ const removeGameFromLibrary = async (
|
|||||||
await resetShopAssets(gameKey);
|
await resetShopAssets(gameKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (game?.remoteId) {
|
if (game.remoteId) {
|
||||||
HydraApi.delete(`/profile/games/${game.remoteId}`).catch(() => {});
|
HydraApi.delete(`/profile/games/${game.remoteId}`).catch(() => {});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -27,6 +27,10 @@ export const getGameAchievementData = async (
|
|||||||
shop: GameShop,
|
shop: GameShop,
|
||||||
useCachedData: boolean
|
useCachedData: boolean
|
||||||
) => {
|
) => {
|
||||||
|
if (shop === "custom") {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
const gameKey = levelKeys.game(shop, objectId);
|
const gameKey = levelKeys.game(shop, objectId);
|
||||||
|
|
||||||
const cachedAchievements = await gameAchievementsSublevel.get(gameKey);
|
const cachedAchievements = await gameAchievementsSublevel.get(gameKey);
|
||||||
|
|||||||
@@ -98,6 +98,11 @@ export function CloudSyncContextProvider({
|
|||||||
);
|
);
|
||||||
|
|
||||||
const getGameArtifacts = useCallback(async () => {
|
const getGameArtifacts = useCallback(async () => {
|
||||||
|
if (shop === "custom") {
|
||||||
|
setArtifacts([]);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const params = new URLSearchParams({
|
const params = new URLSearchParams({
|
||||||
objectId,
|
objectId,
|
||||||
shop,
|
shop,
|
||||||
|
|||||||
@@ -142,10 +142,12 @@ export function GameDetailsContextProvider({
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
window.electron.getGameStats(objectId, shop).then((result) => {
|
if (shop !== "custom") {
|
||||||
if (abortController.signal.aborted) return;
|
window.electron.getGameStats(objectId, shop).then((result) => {
|
||||||
setStats(result);
|
if (abortController.signal.aborted) return;
|
||||||
});
|
setStats(result);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
const assetsPromise = window.electron.getGameAssets(objectId, shop);
|
const assetsPromise = window.electron.getGameAssets(objectId, shop);
|
||||||
|
|
||||||
@@ -167,7 +169,7 @@ export function GameDetailsContextProvider({
|
|||||||
setIsLoading(false);
|
setIsLoading(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
if (userDetails) {
|
if (userDetails && shop !== "custom") {
|
||||||
window.electron
|
window.electron
|
||||||
.getUnlockedAchievements(objectId, shop)
|
.getUnlockedAchievements(objectId, shop)
|
||||||
.then((achievements) => {
|
.then((achievements) => {
|
||||||
|
|||||||
@@ -228,7 +228,7 @@ export function GameDetailsContent() {
|
|||||||
</button>
|
</button>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{game?.shop !== "custom" && shop && objectId && (
|
{shop !== "custom" && shop && objectId && (
|
||||||
<GameReviews
|
<GameReviews
|
||||||
shop={shop}
|
shop={shop}
|
||||||
objectId={objectId}
|
objectId={objectId}
|
||||||
@@ -241,7 +241,7 @@ export function GameDetailsContent() {
|
|||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{game?.shop !== "custom" && <Sidebar />}
|
{shop !== "custom" && <Sidebar />}
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
|
|||||||
@@ -117,7 +117,7 @@ export function GameReviews({
|
|||||||
});
|
});
|
||||||
|
|
||||||
const checkUserReview = useCallback(async () => {
|
const checkUserReview = useCallback(async () => {
|
||||||
if (!objectId || !userDetailsId) return;
|
if (!objectId || !userDetailsId || shop === "custom") return;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const response = await window.electron.hydraApi.get<{
|
const response = await window.electron.hydraApi.get<{
|
||||||
@@ -147,7 +147,7 @@ export function GameReviews({
|
|||||||
|
|
||||||
const loadReviews = useCallback(
|
const loadReviews = useCallback(
|
||||||
async (reset = false) => {
|
async (reset = false) => {
|
||||||
if (!objectId) return;
|
if (!objectId || shop === "custom") return;
|
||||||
|
|
||||||
if (abortControllerRef.current) {
|
if (abortControllerRef.current) {
|
||||||
abortControllerRef.current.abort();
|
abortControllerRef.current.abort();
|
||||||
|
|||||||
@@ -146,6 +146,8 @@ $hero-height: 350px;
|
|||||||
&__game-logo {
|
&__game-logo {
|
||||||
width: 200px;
|
width: 200px;
|
||||||
align-self: flex-end;
|
align-self: flex-end;
|
||||||
|
object-fit: contain;
|
||||||
|
object-position: left bottom;
|
||||||
|
|
||||||
@media (min-width: 768px) {
|
@media (min-width: 768px) {
|
||||||
width: 250px;
|
width: 250px;
|
||||||
@@ -153,6 +155,7 @@ $hero-height: 350px;
|
|||||||
|
|
||||||
@media (min-width: 1024px) {
|
@media (min-width: 1024px) {
|
||||||
width: 300px;
|
width: 300px;
|
||||||
|
max-height: 150px;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
export type GameShop = "steam" | "epic" | "custom";
|
export type GameShop = "steam" | "custom";
|
||||||
|
|
||||||
export type ShortcutLocation = "desktop" | "start_menu";
|
export type ShortcutLocation = "desktop" | "start_menu";
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user