From 6086d363245a254345b6335f580c3d35a092468b Mon Sep 17 00:00:00 2001
From: crupest <crupest@outlook.com>
Date: Tue, 12 Jan 2021 22:13:54 +0800
Subject: ...

---
 FrontEnd/src/app/views/user/index.tsx | 27 +++++----------------------
 1 file changed, 5 insertions(+), 22 deletions(-)

(limited to 'FrontEnd/src/app/views/user/index.tsx')

diff --git a/FrontEnd/src/app/views/user/index.tsx b/FrontEnd/src/app/views/user/index.tsx
index 7c0b1563..bb986178 100644
--- a/FrontEnd/src/app/views/user/index.tsx
+++ b/FrontEnd/src/app/views/user/index.tsx
@@ -1,8 +1,7 @@
 import React, { useState } from "react";
 import { useParams } from "react-router";
 
-import { UiLogicError } from "@/common";
-import { useUser, userInfoService } from "@/services/user";
+import { userInfoService } from "@/services/user";
 
 import TimelinePageTemplate from "../timeline-common/TimelinePageTemplate";
 
@@ -14,54 +13,38 @@ import ChangeAvatarDialog from "./ChangeAvatarDialog";
 const UserPage: React.FC = (_) => {
   const { username } = useParams<{ username: string }>();
 
-  const user = useUser();
-
   const [dialog, setDialog] = useState<null | PersonalTimelineManageItem>(null);
 
   let dialogElement: React.ReactElement | undefined;
 
-  const closeDialogHandler = (): void => {
-    setDialog(null);
-  };
+  const closeDialog = (): void => setDialog(null);
 
   if (dialog === "nickname") {
-    if (user == null) {
-      throw new UiLogicError("Change nickname without login.");
-    }
-
     dialogElement = (
       <ChangeNicknameDialog
         open
-        close={closeDialogHandler}
+        close={closeDialog}
         onProcess={(newNickname) =>
           userInfoService.setNickname(username, newNickname)
         }
       />
     );
   } else if (dialog === "avatar") {
-    if (user == null) {
-      throw new UiLogicError("Change avatar without login.");
-    }
-
     dialogElement = (
       <ChangeAvatarDialog
         open
-        close={closeDialogHandler}
+        close={closeDialog}
         process={(file) => userInfoService.setAvatar(username, file)}
       />
     );
   }
 
-  const onManage = React.useCallback((item: PersonalTimelineManageItem) => {
-    setDialog(item);
-  }, []);
-
   return (
     <>
       <TimelinePageTemplate
         name={`@${username}`}
         UiComponent={UserPageUI}
-        onManage={onManage}
+        onManage={(item) => setDialog(item)}
         notFoundI18nKey="timeline.userNotExist"
       />
       {dialogElement}
-- 
cgit v1.2.3

