mirror of
https://github.com/remvze/moodist.git
synced 2025-09-29 15:30:49 -04:00
feat: reorder sounds in favorites
This commit is contained in:
parent
cb34b59d86
commit
dc9da85e68
@ -18,10 +18,17 @@ export function Categories() {
|
||||
const favorites = useFavoriteStore(useShallow(state => state.favorites));
|
||||
|
||||
const favoriteSounds = useMemo(() => {
|
||||
return categories
|
||||
const favoriteSounds = categories
|
||||
.map(category => category.sounds)
|
||||
.flat()
|
||||
.filter(sound => favorites.includes(sound.id));
|
||||
|
||||
/**
|
||||
* Reorder based on the order of favorites
|
||||
*/
|
||||
return favorites.map(favorite =>
|
||||
favoriteSounds.find(sound => sound.id === favorite),
|
||||
);
|
||||
}, [favorites, categories]);
|
||||
|
||||
useEffect(() => console.log({ favoriteSounds }), [favoriteSounds]);
|
||||
|
Loading…
x
Reference in New Issue
Block a user