aboutsummaryrefslogtreecommitdiff
path: root/Timeline/ClientApp/src/app/user/User.tsx
diff options
context:
space:
mode:
authorcrupest <crupest@outlook.com>2020-08-24 22:59:45 +0800
committercrupest <crupest@outlook.com>2020-08-24 22:59:45 +0800
commitcc0cc154b9506d1961d08cb29fbc29ad815bad69 (patch)
treea50e492d784a553c4fb7bc016819f872c2382247 /Timeline/ClientApp/src/app/user/User.tsx
parent13cf2ab0598adb291066ef64a7b377909ef58525 (diff)
downloadtimeline-cc0cc154b9506d1961d08cb29fbc29ad815bad69.tar.gz
timeline-cc0cc154b9506d1961d08cb29fbc29ad815bad69.tar.bz2
timeline-cc0cc154b9506d1961d08cb29fbc29ad815bad69.zip
...
Diffstat (limited to 'Timeline/ClientApp/src/app/user/User.tsx')
-rw-r--r--Timeline/ClientApp/src/app/user/User.tsx154
1 files changed, 77 insertions, 77 deletions
diff --git a/Timeline/ClientApp/src/app/user/User.tsx b/Timeline/ClientApp/src/app/user/User.tsx
index 67c9d921..6f61cacf 100644
--- a/Timeline/ClientApp/src/app/user/User.tsx
+++ b/Timeline/ClientApp/src/app/user/User.tsx
@@ -1,77 +1,77 @@
-import React, { useState } from 'react';
-import { useParams } from 'react-router';
-
-import { UiLogicError } from '../common';
-import { useUser, userInfoService } from '../data/user';
-import { changeNickname } from './api';
-
-import UserPage from './UserPage';
-import ChangeNicknameDialog from './ChangeNicknameDialog';
-import ChangeAvatarDialog from './ChangeAvatarDialog';
-import TimelinePageTemplate from '../timeline/TimelinePageTemplate';
-import { PersonalTimelineManageItem } from './UserInfoCard';
-
-const User: React.FC = (_) => {
- const { username } = useParams<{ username: string }>();
-
- const user = useUser();
-
- const [dialog, setDialog] = useState<null | PersonalTimelineManageItem>(null);
- const [dataKey, setDataKey] = useState<number>(0);
-
- let dialogElement: React.ReactElement | undefined;
-
- const closeDialogHandler = (): void => {
- setDialog(null);
- };
-
- if (dialog === 'nickname') {
- if (user == null) {
- throw new UiLogicError('Change nickname without login.');
- }
-
- dialogElement = (
- <ChangeNicknameDialog
- open
- close={closeDialogHandler}
- onProcess={(newNickname) => {
- const p = changeNickname(user.token, username, newNickname);
- return p.then((_) => {
- setDataKey(dataKey + 1);
- });
- }}
- />
- );
- } else if (dialog === 'avatar') {
- if (user == null) {
- throw new UiLogicError('Change avatar without login.');
- }
-
- dialogElement = (
- <ChangeAvatarDialog
- open
- close={closeDialogHandler}
- process={(file) => userInfoService.setAvatar(username, file)}
- />
- );
- }
-
- const onManage = React.useCallback((item: PersonalTimelineManageItem) => {
- setDialog(item);
- }, []);
-
- return (
- <>
- <TimelinePageTemplate
- dataVersion={dataKey}
- name={`@${username}`}
- UiComponent={UserPage}
- onManage={onManage}
- notFoundI18nKey="timeline.userNotExist"
- />
- {dialogElement}
- </>
- );
-};
-
-export default User;
+import React, { useState } from "react";
+import { useParams } from "react-router";
+
+import { UiLogicError } from "../common";
+import { useUser, userInfoService } from "../data/user";
+import { changeNickname } from "./api";
+
+import UserPage from "./UserPage";
+import ChangeNicknameDialog from "./ChangeNicknameDialog";
+import ChangeAvatarDialog from "./ChangeAvatarDialog";
+import TimelinePageTemplate from "../timeline/TimelinePageTemplate";
+import { PersonalTimelineManageItem } from "./UserInfoCard";
+
+const User: React.FC = (_) => {
+ const { username } = useParams<{ username: string }>();
+
+ const user = useUser();
+
+ const [dialog, setDialog] = useState<null | PersonalTimelineManageItem>(null);
+ const [dataKey, setDataKey] = useState<number>(0);
+
+ let dialogElement: React.ReactElement | undefined;
+
+ const closeDialogHandler = (): void => {
+ setDialog(null);
+ };
+
+ if (dialog === "nickname") {
+ if (user == null) {
+ throw new UiLogicError("Change nickname without login.");
+ }
+
+ dialogElement = (
+ <ChangeNicknameDialog
+ open
+ close={closeDialogHandler}
+ onProcess={(newNickname) => {
+ const p = changeNickname(user.token, username, newNickname);
+ return p.then((_) => {
+ setDataKey(dataKey + 1);
+ });
+ }}
+ />
+ );
+ } else if (dialog === "avatar") {
+ if (user == null) {
+ throw new UiLogicError("Change avatar without login.");
+ }
+
+ dialogElement = (
+ <ChangeAvatarDialog
+ open
+ close={closeDialogHandler}
+ process={(file) => userInfoService.setAvatar(username, file)}
+ />
+ );
+ }
+
+ const onManage = React.useCallback((item: PersonalTimelineManageItem) => {
+ setDialog(item);
+ }, []);
+
+ return (
+ <>
+ <TimelinePageTemplate
+ dataVersion={dataKey}
+ name={`@${username}`}
+ UiComponent={UserPage}
+ onManage={onManage}
+ notFoundI18nKey="timeline.userNotExist"
+ />
+ {dialogElement}
+ </>
+ );
+};
+
+export default User;