diff options
author | crupest <crupest@outlook.com> | 2021-01-13 00:08:23 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-01-13 00:08:23 +0800 |
commit | cf14e89a51919e053ba89b0c78ee71940b18e40a (patch) | |
tree | ec790b67e00f664815a785786083abdb108c9c99 /FrontEnd/src/app/views/user/index.tsx | |
parent | 43cf429cb81e928a6466522864682bd4a68ea42e (diff) | |
parent | e6dff0d19d524d14a3adff7803d9a56264e85f2e (diff) | |
download | timeline-cf14e89a51919e053ba89b0c78ee71940b18e40a.tar.gz timeline-cf14e89a51919e053ba89b0c78ee71940b18e40a.tar.bz2 timeline-cf14e89a51919e053ba89b0c78ee71940b18e40a.zip |
Merge pull request #208 from crupest/front-dev
Front end development.
Diffstat (limited to 'FrontEnd/src/app/views/user/index.tsx')
-rw-r--r-- | FrontEnd/src/app/views/user/index.tsx | 27 |
1 files changed, 5 insertions, 22 deletions
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} |