diff options
author | crupest <crupest@outlook.com> | 2020-06-04 00:18:50 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2020-06-04 00:18:50 +0800 |
commit | fccd6b4ca8ed7420f25f0c4298fde311bc1e09d0 (patch) | |
tree | 787cda66f8997ba842601a261a36b6de95398675 /Timeline/ClientApp/src/user/User.tsx | |
parent | 92e50c4a3ea250dc18c76bc8c29d86d486e63772 (diff) | |
download | timeline-fccd6b4ca8ed7420f25f0c4298fde311bc1e09d0.tar.gz timeline-fccd6b4ca8ed7420f25f0c4298fde311bc1e09d0.tar.bz2 timeline-fccd6b4ca8ed7420f25f0c4298fde311bc1e09d0.zip |
refactor(front): Make codes lint-clean!
Diffstat (limited to 'Timeline/ClientApp/src/user/User.tsx')
-rw-r--r-- | Timeline/ClientApp/src/user/User.tsx | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/Timeline/ClientApp/src/user/User.tsx b/Timeline/ClientApp/src/user/User.tsx index 7bdd64b7..a281be42 100644 --- a/Timeline/ClientApp/src/user/User.tsx +++ b/Timeline/ClientApp/src/user/User.tsx @@ -10,6 +10,7 @@ import ChangeNicknameDialog from './ChangeNicknameDialog'; import ChangeAvatarDialog from './ChangeAvatarDialog';
import TimelinePageTemplate from '../timeline/TimelinePageTemplate';
import { PersonalTimelineManageItem } from './UserInfoCard';
+import { UiLogicError } from '../common';
const User: React.FC = (_) => {
const { username } = useParams<{ username: string }>();
@@ -26,12 +27,16 @@ const User: React.FC = (_) => { };
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);
+ const p = changeNickname(user.token, username, newNickname);
return p.then((_) => {
setDataKey(dataKey + 1);
});
@@ -39,11 +44,15 @@ const User: React.FC = (_) => { />
);
} else if (dialog === 'avatar') {
+ if (user == null) {
+ throw new UiLogicError('Change avatar without login.');
+ }
+
dialogElement = (
<ChangeAvatarDialog
open
close={closeDialogHandler}
- process={(file) => changeAvatar(user!.token, username, file, file.type)}
+ process={(file) => changeAvatar(user.token, username, file, file.type)}
/>
);
}
|