mirror of
https://github.com/hydralauncher/hydra.git
synced 2025-01-23 13:34:54 +03:00
feat: temp remove fetch from local cache
This commit is contained in:
parent
c8022896a6
commit
be08fb6d14
13
.github/workflows/build.yml
vendored
13
.github/workflows/build.yml
vendored
@ -14,6 +14,19 @@ jobs:
|
||||
- name: Check out Git repository
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Cache node modules
|
||||
id: cache-npm
|
||||
uses: actions/cache@v3
|
||||
env:
|
||||
cache-name: cache-node-modules
|
||||
with:
|
||||
path: ~/.npm
|
||||
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/yarn.lock') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-build-${{ env.cache-name }}-
|
||||
${{ runner.os }}-build-
|
||||
${{ runner.os }}-
|
||||
|
||||
- name: Install Node.js
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
|
13
.github/workflows/lint.yml
vendored
13
.github/workflows/lint.yml
vendored
@ -10,6 +10,19 @@ jobs:
|
||||
- name: Check out Git repository
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Cache node modules
|
||||
id: cache-npm
|
||||
uses: actions/cache@v3
|
||||
env:
|
||||
cache-name: cache-node-modules
|
||||
with:
|
||||
path: ~/.npm
|
||||
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/yarn.lock') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-build-${{ env.cache-name }}-
|
||||
${{ runner.os }}-build-
|
||||
${{ runner.os }}-
|
||||
|
||||
- name: Install Node.js
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
|
@ -11,16 +11,14 @@ import {
|
||||
userPreferencesRepository,
|
||||
} from "@main/repository";
|
||||
import { getGameAchievementData } from "@main/services/achievements/get-game-achievement-data";
|
||||
import { HydraApi, logger } from "@main/services";
|
||||
import { HydraApi } from "@main/services";
|
||||
|
||||
const getAchievementLocalUser = async (shop: string, objectId: string) => {
|
||||
const cachedAchievements = await gameAchievementRepository.findOne({
|
||||
where: { objectId, shop },
|
||||
});
|
||||
|
||||
const achievementsData: AchievementData[] = cachedAchievements?.achievements
|
||||
? JSON.parse(cachedAchievements.achievements)
|
||||
: await getGameAchievementData(objectId, shop);
|
||||
const achievementsData = await getGameAchievementData(objectId, shop);
|
||||
|
||||
const unlockedAchievements = JSON.parse(
|
||||
cachedAchievements?.unlockedAchievements || "[]"
|
||||
@ -28,8 +26,6 @@ const getAchievementLocalUser = async (shop: string, objectId: string) => {
|
||||
|
||||
return achievementsData
|
||||
.map((achievementData) => {
|
||||
logger.info("unclockedAchievements", unlockedAchievements);
|
||||
|
||||
const unlockedAchiementData = unlockedAchievements.find(
|
||||
(localAchievement) => {
|
||||
return (
|
||||
@ -77,13 +73,10 @@ const getAchievementsRemoteUser = async (
|
||||
where: { id: 1 },
|
||||
});
|
||||
|
||||
const cachedAchievements = await gameAchievementRepository.findOne({
|
||||
where: { objectId, shop },
|
||||
});
|
||||
|
||||
const achievementsData: AchievementData[] = cachedAchievements?.achievements
|
||||
? JSON.parse(cachedAchievements.achievements)
|
||||
: await getGameAchievementData(objectId, shop);
|
||||
const achievementsData: AchievementData[] = await getGameAchievementData(
|
||||
objectId,
|
||||
shop
|
||||
);
|
||||
|
||||
const unlockedAchievements = await HydraApi.get<RemoteUnlockedAchievement[]>(
|
||||
`/users/${userId}/games/achievements`,
|
||||
|
@ -3,6 +3,7 @@ import {
|
||||
userPreferencesRepository,
|
||||
} from "@main/repository";
|
||||
import { HydraApi } from "../hydra-api";
|
||||
import { AchievementData } from "@types";
|
||||
|
||||
export const getGameAchievementData = async (
|
||||
objectId: string,
|
||||
@ -12,13 +13,13 @@ export const getGameAchievementData = async (
|
||||
where: { id: 1 },
|
||||
});
|
||||
|
||||
return HydraApi.get("/games/achievements", {
|
||||
return HydraApi.get<AchievementData[]>("/games/achievements", {
|
||||
shop,
|
||||
objectId,
|
||||
language: userPreferences?.language || "en",
|
||||
})
|
||||
.then(async (achievements) => {
|
||||
await gameAchievementRepository.upsert(
|
||||
.then((achievements) => {
|
||||
gameAchievementRepository.upsert(
|
||||
{
|
||||
objectId,
|
||||
shop,
|
||||
@ -29,5 +30,13 @@ export const getGameAchievementData = async (
|
||||
|
||||
return achievements;
|
||||
})
|
||||
.catch(() => []);
|
||||
.catch(() => {
|
||||
return gameAchievementRepository
|
||||
.findOne({
|
||||
where: { objectId, shop },
|
||||
})
|
||||
.then((gameAchievements) => {
|
||||
return JSON.parse(gameAchievements?.achievements || "[]");
|
||||
});
|
||||
});
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user