mirror of
https://github.com/hydralauncher/hydra.git
synced 2026-01-11 13:56:16 +00:00
Merge pull request #1834 from hydralauncher/fix/custom-games-unnecessary-requests
fix: disabling unnecessary api calls when game is custom
This commit is contained in:
@@ -6,6 +6,10 @@ import { gamesShopAssetsSublevel, levelKeys } from "@main/level";
|
||||
const LOCAL_CACHE_EXPIRATION = 1000 * 60 * 60 * 8; // 8 hours
|
||||
|
||||
export const getGameAssets = async (objectId: string, shop: GameShop) => {
|
||||
if (shop === "custom") {
|
||||
return null;
|
||||
}
|
||||
|
||||
const cachedAssets = await gamesShopAssetsSublevel.get(
|
||||
levelKeys.game(shop, objectId)
|
||||
);
|
||||
|
||||
@@ -10,6 +10,10 @@ const getGameStats = async (
|
||||
objectId: string,
|
||||
shop: GameShop
|
||||
) => {
|
||||
if (shop === "custom") {
|
||||
return null;
|
||||
}
|
||||
|
||||
const cachedStats = await gamesStatsCacheSublevel.get(
|
||||
levelKeys.game(shop, objectId)
|
||||
);
|
||||
|
||||
@@ -13,7 +13,9 @@ const addGameToFavorites = async (
|
||||
const game = await gamesSublevel.get(gameKey);
|
||||
if (!game) return;
|
||||
|
||||
HydraApi.put(`/profile/games/${shop}/${objectId}/favorite`).catch(() => {});
|
||||
if (shop !== "custom") {
|
||||
HydraApi.put(`/profile/games/${shop}/${objectId}/favorite`).catch(() => {});
|
||||
}
|
||||
|
||||
try {
|
||||
await gamesSublevel.put(gameKey, {
|
||||
|
||||
@@ -13,7 +13,11 @@ const removeGameFromFavorites = async (
|
||||
const game = await gamesSublevel.get(gameKey);
|
||||
if (!game) return;
|
||||
|
||||
HydraApi.put(`/profile/games/${shop}/${objectId}/unfavorite`).catch(() => {});
|
||||
if (shop !== "custom") {
|
||||
HydraApi.put(`/profile/games/${shop}/${objectId}/unfavorite`).catch(
|
||||
() => {}
|
||||
);
|
||||
}
|
||||
|
||||
try {
|
||||
await gamesSublevel.put(gameKey, {
|
||||
|
||||
@@ -27,6 +27,10 @@ export const getGameAchievementData = async (
|
||||
shop: GameShop,
|
||||
useCachedData: boolean
|
||||
) => {
|
||||
if (shop === "custom") {
|
||||
return [];
|
||||
}
|
||||
|
||||
const gameKey = levelKeys.game(shop, objectId);
|
||||
|
||||
const cachedAchievements = await gameAchievementsSublevel.get(gameKey);
|
||||
|
||||
@@ -98,6 +98,11 @@ export function CloudSyncContextProvider({
|
||||
);
|
||||
|
||||
const getGameArtifacts = useCallback(async () => {
|
||||
if (shop === "custom") {
|
||||
setArtifacts([]);
|
||||
return;
|
||||
}
|
||||
|
||||
const params = new URLSearchParams({
|
||||
objectId,
|
||||
shop,
|
||||
|
||||
@@ -142,10 +142,12 @@ export function GameDetailsContextProvider({
|
||||
}
|
||||
});
|
||||
|
||||
window.electron.getGameStats(objectId, shop).then((result) => {
|
||||
if (abortController.signal.aborted) return;
|
||||
setStats(result);
|
||||
});
|
||||
if (shop !== "custom") {
|
||||
window.electron.getGameStats(objectId, shop).then((result) => {
|
||||
if (abortController.signal.aborted) return;
|
||||
setStats(result);
|
||||
});
|
||||
}
|
||||
|
||||
const assetsPromise = window.electron.getGameAssets(objectId, shop);
|
||||
|
||||
@@ -167,7 +169,7 @@ export function GameDetailsContextProvider({
|
||||
setIsLoading(false);
|
||||
});
|
||||
|
||||
if (userDetails) {
|
||||
if (userDetails && shop !== "custom") {
|
||||
window.electron
|
||||
.getUnlockedAchievements(objectId, shop)
|
||||
.then((achievements) => {
|
||||
|
||||
@@ -117,7 +117,7 @@ export function GameReviews({
|
||||
});
|
||||
|
||||
const checkUserReview = useCallback(async () => {
|
||||
if (!objectId || !userDetailsId) return;
|
||||
if (!objectId || !userDetailsId || shop === "custom") return;
|
||||
|
||||
try {
|
||||
const response = await window.electron.hydraApi.get<{
|
||||
@@ -147,7 +147,7 @@ export function GameReviews({
|
||||
|
||||
const loadReviews = useCallback(
|
||||
async (reset = false) => {
|
||||
if (!objectId) return;
|
||||
if (!objectId || shop === "custom") return;
|
||||
|
||||
if (abortControllerRef.current) {
|
||||
abortControllerRef.current.abort();
|
||||
|
||||
Reference in New Issue
Block a user