mirror of
https://github.com/hydralauncher/hydra.git
synced 2026-01-29 13:51:02 +00:00
fix: disabling unnecessary api calls if game is custom
This commit is contained in:
@@ -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)
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -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,12 @@ export function CloudSyncContextProvider({
|
|||||||
);
|
);
|
||||||
|
|
||||||
const getGameArtifacts = useCallback(async () => {
|
const getGameArtifacts = useCallback(async () => {
|
||||||
|
// Don't make API requests for custom games
|
||||||
|
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) => {
|
||||||
|
|||||||
@@ -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();
|
||||||
|
|||||||
Reference in New Issue
Block a user