chore: update user menu items (#2179)

This commit is contained in:
boojack
2023-08-26 23:11:45 +08:00
committed by GitHub
parent 18fb02a1ec
commit c67a69629e
6 changed files with 45 additions and 56 deletions

View File

@ -1,25 +1,25 @@
import { useEffect } from "react";
import { useEffect, useState } from "react";
import { toast } from "react-hot-toast";
import FloatingNavButton from "@/components/FloatingNavButton";
import MemoFilter from "@/components/MemoFilter";
import MemoList from "@/components/MemoList";
import UserAvatar from "@/components/UserAvatar";
import useLoading from "@/hooks/useLoading";
import { useGlobalStore, useUserStore } from "@/store/module";
import { useUserStore } from "@/store/module";
import { useTranslate } from "@/utils/i18n";
const UserProfile = () => {
const t = useTranslate();
const globalStore = useGlobalStore();
const userStore = useUserStore();
const loadingState = useLoading();
const user = userStore.state.user;
const [user, setUser] = useState<User>();
useEffect(() => {
const currentUsername = userStore.getCurrentUsername();
userStore
.getUserByUsername(currentUsername)
.then(() => {
.then((user) => {
setUser(user);
loadingState.setFinish();
})
.catch((error) => {
@ -28,12 +28,6 @@ const UserProfile = () => {
});
}, [userStore.getCurrentUsername()]);
useEffect(() => {
if (user?.setting.locale) {
globalStore.setLocale(user.setting.locale);
}
}, [user?.setting.locale]);
return (
<>
<section className="relative top-0 w-full min-h-full overflow-x-hidden bg-zinc-100 dark:bg-zinc-800">