mirror of
https://github.com/umami-software/umami.git
synced 2026-02-06 05:37:20 +01:00
Convert useModified into a real hook.
This commit is contained in:
parent
a426c242cb
commit
91e3dff7f5
24 changed files with 63 additions and 48 deletions
15
src/components/hooks/useModified.ts
Normal file
15
src/components/hooks/useModified.ts
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
import useStore from 'store/modified';
|
||||
|
||||
export function useModified(key?: string) {
|
||||
const modified = useStore(state => state?.[key]);
|
||||
|
||||
const touch = (id?: string) => {
|
||||
if (id || key) {
|
||||
useStore.setState({ [id || key]: Date.now() });
|
||||
}
|
||||
};
|
||||
|
||||
return { modified, touch };
|
||||
}
|
||||
|
||||
export default useModified;
|
||||
Loading…
Add table
Add a link
Reference in a new issue