mirror of
https://github.com/hydralauncher/hydra.git
synced 2026-01-29 05:41:03 +00:00
first commit
This commit is contained in:
16
src/renderer/hooks/use-library.ts
Normal file
16
src/renderer/hooks/use-library.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
import { useCallback } from "react";
|
||||
import { useAppDispatch, useAppSelector } from "./redux";
|
||||
import { setLibrary } from "@renderer/features";
|
||||
|
||||
export function useLibrary() {
|
||||
const dispatch = useAppDispatch();
|
||||
const library = useAppSelector((state) => state.library.value);
|
||||
|
||||
const updateLibrary = useCallback(async () => {
|
||||
return window.electron
|
||||
.getLibrary()
|
||||
.then((updatedLibrary) => dispatch(setLibrary(updatedLibrary)));
|
||||
}, [dispatch]);
|
||||
|
||||
return { library, updateLibrary };
|
||||
}
|
||||
Reference in New Issue
Block a user