chore: use user v2 api in frontend

This commit is contained in:
Steven
2023-09-10 22:03:12 +08:00
parent 93f062d0b9
commit 3ad0832516
11 changed files with 205 additions and 168 deletions

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