chore: clean duplicated requests

This commit is contained in:
Steven
2023-09-10 11:43:38 +08:00
parent ca336af4fa
commit 866937787c
16 changed files with 56 additions and 69 deletions

View File

@ -6,18 +6,20 @@ import MemoList from "@/components/MemoList";
import UserAvatar from "@/components/UserAvatar";
import useLoading from "@/hooks/useLoading";
import { useUserStore } from "@/store/module";
import { useUserV1Store } from "@/store/v1";
import { useTranslate } from "@/utils/i18n";
const UserProfile = () => {
const t = useTranslate();
const userStore = useUserStore();
const userV1Store = useUserV1Store();
const loadingState = useLoading();
const [user, setUser] = useState<User>();
useEffect(() => {
const currentUsername = userStore.getCurrentUsername();
userStore
.getUserByUsername(currentUsername)
userV1Store
.getOrFetchUserByUsername(currentUsername)
.then((user) => {
setUser(user);
loadingState.setFinish();