mirror of
https://github.com/hydralauncher/hydra.git
synced 2026-01-18 00:33:59 +00:00
Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
20c0d3174b |
@@ -7,9 +7,25 @@ export function useLibrary() {
|
|||||||
const library = useAppSelector((state) => state.library.value);
|
const library = useAppSelector((state) => state.library.value);
|
||||||
|
|
||||||
const updateLibrary = useCallback(async () => {
|
const updateLibrary = useCallback(async () => {
|
||||||
return window.electron
|
return window.electron.getLibrary().then(async (updatedLibrary) => {
|
||||||
.getLibrary()
|
const libraryWithAchievements = await Promise.all(
|
||||||
.then((updatedLibrary) => dispatch(setLibrary(updatedLibrary)));
|
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]);
|
}, [dispatch]);
|
||||||
|
|
||||||
return { library, updateLibrary };
|
return { library, updateLibrary };
|
||||||
|
|||||||
Reference in New Issue
Block a user