mirror of
https://github.com/usememos/memos.git
synced 2025-06-05 22:09:59 +02:00
chore: use user v2 api in frontend
This commit is contained in:
19
web/src/hooks/useCurrentUser.ts
Normal file
19
web/src/hooks/useCurrentUser.ts
Normal file
@ -0,0 +1,19 @@
|
||||
import { useEffect } from "react";
|
||||
import { useUserStore } from "@/store/module";
|
||||
import { useUserV1Store } from "@/store/v1";
|
||||
|
||||
const useCurrentUser = () => {
|
||||
const userStore = useUserStore();
|
||||
const userV1Store = useUserV1Store();
|
||||
const currentUsername = userStore.getCurrentUsername();
|
||||
|
||||
useEffect(() => {
|
||||
if (currentUsername) {
|
||||
userV1Store.getOrFetchUserByUsername(currentUsername);
|
||||
}
|
||||
}, [currentUsername]);
|
||||
|
||||
return userV1Store.getUserByUsername(currentUsername);
|
||||
};
|
||||
|
||||
export default useCurrentUser;
|
Reference in New Issue
Block a user