mirror of
https://github.com/hydralauncher/hydra.git
synced 2026-01-11 13:56:16 +00:00
feat: use promise all on pre search achievement
This commit is contained in:
@@ -289,24 +289,17 @@ export class AchievementWatcherManager {
|
||||
}
|
||||
|
||||
public static async preSearchAchievements() {
|
||||
await setTimeout(4000);
|
||||
|
||||
try {
|
||||
const gameAchievementFiles =
|
||||
process.platform === "win32"
|
||||
? await this.getGameAchievementFilesWindows()
|
||||
: await this.getGameAchievementFilesLinux();
|
||||
|
||||
const newAchievementsCount: number[] = [];
|
||||
|
||||
for (const { game, achievementFiles } of gameAchievementFiles) {
|
||||
const result = await this.preProcessGameAchievementFiles(
|
||||
game,
|
||||
achievementFiles
|
||||
);
|
||||
|
||||
newAchievementsCount.push(result);
|
||||
}
|
||||
const newAchievementsCount = await Promise.all(
|
||||
gameAchievementFiles.map(({ game, achievementFiles }) => {
|
||||
return this.preProcessGameAchievementFiles(game, achievementFiles);
|
||||
})
|
||||
);
|
||||
|
||||
const totalNewGamesWithAchievements = newAchievementsCount.filter(
|
||||
(achievements) => achievements
|
||||
@@ -326,6 +319,8 @@ export class AchievementWatcherManager {
|
||||
);
|
||||
|
||||
if (userPreferences.achievementNotificationsEnabled !== false) {
|
||||
await setTimeout(4000);
|
||||
|
||||
if (userPreferences.achievementCustomNotificationsEnabled !== false) {
|
||||
WindowManager.notificationWindow?.webContents.send(
|
||||
"on-combined-achievements-unlocked",
|
||||
|
||||
@@ -13,9 +13,8 @@ export const mergeWithRemoteGames = async () => {
|
||||
return HydraApi.get<ProfileGame[]>("/profile/games")
|
||||
.then(async (response) => {
|
||||
for (const game of response) {
|
||||
const localGame = await gamesSublevel.get(
|
||||
levelKeys.game(game.shop, game.objectId)
|
||||
);
|
||||
const gameKey = levelKeys.game(game.shop, game.objectId);
|
||||
const localGame = await gamesSublevel.get(gameKey);
|
||||
|
||||
if (localGame) {
|
||||
const updatedLastTimePlayed =
|
||||
@@ -30,7 +29,7 @@ export const mergeWithRemoteGames = async () => {
|
||||
? game.playTimeInMilliseconds
|
||||
: localGame.playTimeInMilliseconds;
|
||||
|
||||
await gamesSublevel.put(levelKeys.game(game.shop, game.objectId), {
|
||||
await gamesSublevel.put(gameKey, {
|
||||
...localGame,
|
||||
remoteId: game.id,
|
||||
lastTimePlayed: updatedLastTimePlayed,
|
||||
@@ -38,7 +37,7 @@ export const mergeWithRemoteGames = async () => {
|
||||
favorite: game.isFavorite ?? localGame.favorite,
|
||||
});
|
||||
} else {
|
||||
await gamesSublevel.put(levelKeys.game(game.shop, game.objectId), {
|
||||
await gamesSublevel.put(gameKey, {
|
||||
objectId: game.objectId,
|
||||
title: game.title,
|
||||
remoteId: game.id,
|
||||
@@ -51,20 +50,17 @@ export const mergeWithRemoteGames = async () => {
|
||||
});
|
||||
}
|
||||
|
||||
await gamesShopAssetsSublevel.put(
|
||||
levelKeys.game(game.shop, game.objectId),
|
||||
{
|
||||
shop: game.shop,
|
||||
objectId: game.objectId,
|
||||
title: game.title,
|
||||
coverImageUrl: game.coverImageUrl,
|
||||
libraryHeroImageUrl: game.libraryHeroImageUrl,
|
||||
libraryImageUrl: game.libraryImageUrl,
|
||||
logoImageUrl: game.logoImageUrl,
|
||||
iconUrl: game.iconUrl,
|
||||
logoPosition: game.logoPosition,
|
||||
}
|
||||
);
|
||||
await gamesShopAssetsSublevel.put(gameKey, {
|
||||
shop: game.shop,
|
||||
objectId: game.objectId,
|
||||
title: game.title,
|
||||
coverImageUrl: game.coverImageUrl,
|
||||
libraryHeroImageUrl: game.libraryHeroImageUrl,
|
||||
libraryImageUrl: game.libraryImageUrl,
|
||||
logoImageUrl: game.logoImageUrl,
|
||||
iconUrl: game.iconUrl,
|
||||
logoPosition: game.logoPosition,
|
||||
});
|
||||
}
|
||||
})
|
||||
.catch(() => {});
|
||||
|
||||
Reference in New Issue
Block a user