refactor(frontend): use auth service

This commit is contained in:
Steven
2023-12-01 09:15:02 +08:00
parent b944418257
commit e83d483454
19 changed files with 136 additions and 299 deletions

View File

@ -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;