mirror of
https://github.com/usememos/memos.git
synced 2025-06-05 22:09:59 +02:00
refactor(frontend): use auth service
This commit is contained in:
@ -1,19 +1,9 @@
|
||||
import { useEffect } from "react";
|
||||
import { useUserStore } from "@/store/module";
|
||||
import { useUserV1Store } from "@/store/v1";
|
||||
import { User } from "@/types/proto/api/v2/user_service";
|
||||
|
||||
const useCurrentUser = () => {
|
||||
const userStore = useUserStore();
|
||||
const userV1Store = useUserV1Store();
|
||||
const currentUsername = userStore.state.user?.username;
|
||||
|
||||
useEffect(() => {
|
||||
if (currentUsername) {
|
||||
userV1Store.getOrFetchUserByUsername(currentUsername);
|
||||
}
|
||||
}, [currentUsername]);
|
||||
|
||||
return userV1Store.getUserByUsername(currentUsername || "");
|
||||
return userV1Store.currentUser as User;
|
||||
};
|
||||
|
||||
export default useCurrentUser;
|
||||
|
Reference in New Issue
Block a user