mirror of
https://github.com/hydralauncher/hydra.git
synced 2026-01-11 05:46:17 +00:00
test
This commit is contained in:
@@ -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 };
|
||||
|
||||
Reference in New Issue
Block a user