diff --git a/web/src/components/FloatingNavButton.tsx b/web/src/components/FloatingNavButton.tsx
index 3ea05e3a..a5d9e8c2 100644
--- a/web/src/components/FloatingNavButton.tsx
+++ b/web/src/components/FloatingNavButton.tsx
@@ -1,4 +1,4 @@
-import { Dropdown, IconButton, Menu, MenuButton, MenuItem } from "@mui/joy";
+import { Dropdown, IconButton, Menu, MenuButton } from "@mui/joy";
import { useNavigate } from "react-router-dom";
import Icon from "./Icon";
@@ -11,13 +11,20 @@ const FloatingNavButton = () => {
-
+
>
diff --git a/web/src/components/Settings/MemberSection.tsx b/web/src/components/Settings/MemberSection.tsx
index 7ac73a36..695d6969 100644
--- a/web/src/components/Settings/MemberSection.tsx
+++ b/web/src/components/Settings/MemberSection.tsx
@@ -171,37 +171,35 @@ const PreferencesSection = () => {
)}
diff --git a/web/src/components/UserBanner.tsx b/web/src/components/UserBanner.tsx
index 48866f3d..f1d1e185 100644
--- a/web/src/components/UserBanner.tsx
+++ b/web/src/components/UserBanner.tsx
@@ -23,7 +23,7 @@ const UserBanner = () => {
}, [user]);
const handleMyAccountClick = () => {
- navigate("/setting");
+ navigate(`/u/${user?.username}`);
};
const handleAboutBtnClick = () => {
@@ -41,7 +41,7 @@ const UserBanner = () => {
className="w-auto"
trigger={
-
+
{user != undefined ? username : systemStatus.customizedProfile.name}
@@ -60,7 +60,7 @@ const UserBanner = () => {
className="w-full px-3 truncate text-left leading-10 cursor-pointer rounded flex flex-row justify-start items-center dark:text-gray-200 hover:bg-gray-100 dark:hover:bg-zinc-800"
onClick={handleMyAccountClick}
>
-
{t("setting.my-account")}
+
{t("common.profile")}
{
const t = useTranslate();
- const globalStore = useGlobalStore();
const userStore = useUserStore();
const loadingState = useLoading();
- const user = userStore.state.user;
+ const [user, setUser] = useState();
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 (
<>
diff --git a/web/src/store/module/user.ts b/web/src/store/module/user.ts
index 1d1cc754..34f01968 100644
--- a/web/src/store/module/user.ts
+++ b/web/src/store/module/user.ts
@@ -71,16 +71,6 @@ export const initialUserState = async () => {
}
};
-const getUserIdFromPath = () => {
- const pathname = window.location.pathname;
- const userIdRegex = /^\/u\/(\d+).*/;
- const result = pathname.match(userIdRegex);
- if (result && result.length === 2) {
- return Number(result[1]);
- }
- return undefined;
-};
-
const getUsernameFromPath = () => {
const pathname = window.location.pathname;
const usernameRegex = /^\/u\/(\w+).*/;
@@ -109,7 +99,7 @@ export const useUserStore = () => {
const state = useAppSelector((state) => state.user);
const isVisitorMode = () => {
- return state.user === undefined || (getUsernameFromPath() && state.user.username !== getUsernameFromPath());
+ return state.user === undefined || getUsernameFromPath();
};
return {
@@ -118,7 +108,6 @@ export const useUserStore = () => {
return store.getState().user;
},
isVisitorMode,
- getUserIdFromPath,
getUsernameFromPath,
doSignIn,
doSignOut,