This commit is contained in:
Zamitto
2025-11-12 14:37:44 -03:00
parent cd3fa10bf7
commit 20c0d3174b

View File

@@ -7,9 +7,25 @@ export function useLibrary() {
const library = useAppSelector((state) => state.library.value);
const updateLibrary = useCallback(async () => {
return window.electron
.getLibrary()
.then((updatedLibrary) => dispatch(setLibrary(updatedLibrary)));
return window.electron.getLibrary().then(async (updatedLibrary) => {
const libraryWithAchievements = await Promise.all(
updatedLibrary.map(async (game) => {
const unlockedAchievements =
await window.electron.getUnlockedAchievements(
game.objectId,
game.shop
);
return {
...game,
unlockedAchievementCount:
game.unlockedAchievementCount || unlockedAchievements.length,
};
})
);
dispatch(setLibrary(libraryWithAchievements));
});
}, [dispatch]);
return { library, updateLibrary };