1 import { Component, linkEvent } from 'inferno';
2 import { Link } from 'inferno-router';
3 import { Subscription } from 'rxjs';
4 import { retryWhen, delay, take } from 'rxjs/operators';
22 WebSocketJsonResponse,
25 } from '../interfaces';
26 import { WebSocketService, UserService } from '../services';
31 capitalizeFirstLetter,
40 createPostLikeFindRes,
44 import { PostListing } from './post-listing';
45 import { UserListing } from './user-listing';
46 import { SortSelect } from './sort-select';
47 import { ListingTypeSelect } from './listing-type-select';
48 import { CommentNodes } from './comment-nodes';
49 import { MomentTime } from './moment-time';
50 import { i18n } from '../i18next';
63 follows: Array<CommunityUser>;
64 moderates: Array<CommunityUser>;
65 comments: Array<Comment>;
68 admins: Array<UserView>;
73 avatarLoading: boolean;
74 userSettingsForm: UserSettingsForm;
75 userSettingsLoading: boolean;
76 deleteAccountLoading: boolean;
77 deleteAccountShowConfirm: boolean;
78 deleteAccountForm: DeleteAccountForm;
82 export class User extends Component<any, UserState> {
83 private subscription: Subscription;
84 private emptyState: UserState = {
89 number_of_posts: null,
91 number_of_comments: null,
96 send_notifications_to_email: null,
108 avatarLoading: false,
109 view: this.getViewFromProps(this.props),
110 sort: this.getSortTypeFromProps(this.props),
111 page: this.getPageFromProps(this.props),
115 default_sort_type: null,
116 default_listing_type: null,
119 send_notifications_to_email: null,
122 userSettingsLoading: null,
123 deleteAccountLoading: null,
124 deleteAccountShowConfirm: false,
131 creator_id: undefined,
132 published: undefined,
133 creator_name: undefined,
134 number_of_users: undefined,
135 number_of_posts: undefined,
136 number_of_comments: undefined,
137 number_of_communities: undefined,
138 enable_downvotes: undefined,
139 open_registration: undefined,
140 enable_nsfw: undefined,
144 constructor(props: any, context: any) {
145 super(props, context);
147 this.state = this.emptyState;
148 this.handleSortChange = this.handleSortChange.bind(this);
149 this.handleUserSettingsSortTypeChange = this.handleUserSettingsSortTypeChange.bind(
152 this.handleUserSettingsListingTypeChange = this.handleUserSettingsListingTypeChange.bind(
156 this.state.user_id = Number(this.props.match.params.id);
157 this.state.username = this.props.match.params.username;
159 this.subscription = WebSocketService.Instance.subject
160 .pipe(retryWhen(errors => errors.pipe(delay(3000), take(10))))
162 msg => this.parseMessage(msg),
163 err => console.error(err),
164 () => console.log('complete')
168 WebSocketService.Instance.getSite();
171 get isCurrentUser() {
173 UserService.Instance.user &&
174 UserService.Instance.user.id == this.state.user.id
178 getViewFromProps(props: any): View {
179 return props.match.params.view
180 ? View[capitalizeFirstLetter(props.match.params.view)]
184 getSortTypeFromProps(props: any): SortType {
185 return props.match.params.sort
186 ? routeSortTypeToEnum(props.match.params.sort)
190 getPageFromProps(props: any): number {
191 return props.match.params.page ? Number(props.match.params.page) : 1;
194 componentWillUnmount() {
195 this.subscription.unsubscribe();
198 // Necessary for back button for some reason
199 componentWillReceiveProps(nextProps: any) {
201 nextProps.history.action == 'POP' ||
202 nextProps.history.action == 'PUSH'
204 this.state.view = this.getViewFromProps(nextProps);
205 this.state.sort = this.getSortTypeFromProps(nextProps);
206 this.state.page = this.getPageFromProps(nextProps);
207 this.setState(this.state);
212 componentDidUpdate(lastProps: any, _lastState: UserState, _snapshot: any) {
213 // Necessary if you are on a post and you click another post (same route)
215 lastProps.location.pathname.split('/')[2] !==
216 lastProps.history.location.pathname.split('/')[2]
218 // Couldnt get a refresh working. This does for now.
225 <div class="container">
226 {this.state.loading ? (
228 <svg class="icon icon-spinner spin">
229 <use xlinkHref="#icon-spinner"></use>
234 <div class="col-12 col-md-8">
236 {this.state.user.avatar && showAvatars() && (
240 src={this.state.user.avatar}
241 class="rounded-circle mr-2"
244 <span>/u/{this.state.user.name}</span>
247 {this.state.view == View.Overview && this.overview()}
248 {this.state.view == View.Comments && this.comments()}
249 {this.state.view == View.Posts && this.posts()}
250 {this.state.view == View.Saved && this.overview()}
253 <div class="col-12 col-md-4">
255 {this.isCurrentUser && this.userSettings()}
267 <div class="btn-group btn-group-toggle">
269 className={`btn btn-sm btn-secondary pointer btn-outline-light
270 ${this.state.view == View.Overview && 'active'}
275 value={View.Overview}
276 checked={this.state.view == View.Overview}
277 onChange={linkEvent(this, this.handleViewChange)}
282 className={`btn btn-sm btn-secondary pointer btn-outline-light
283 ${this.state.view == View.Comments && 'active'}
288 value={View.Comments}
289 checked={this.state.view == View.Comments}
290 onChange={linkEvent(this, this.handleViewChange)}
295 className={`btn btn-sm btn-secondary pointer btn-outline-light
296 ${this.state.view == View.Posts && 'active'}
302 checked={this.state.view == View.Posts}
303 onChange={linkEvent(this, this.handleViewChange)}
308 className={`btn btn-sm btn-secondary pointer btn-outline-light
309 ${this.state.view == View.Saved && 'active'}
315 checked={this.state.view == View.Saved}
316 onChange={linkEvent(this, this.handleViewChange)}
326 <div className="mb-2">
327 <span class="mr-3">{this.viewRadios()}</span>
329 sort={this.state.sort}
330 onChange={this.handleSortChange}
334 href={`/feeds/u/${this.state.username}.xml?sort=${
335 SortType[this.state.sort]
341 <svg class="icon mx-2 text-muted small">
342 <use xlinkHref="#icon-rss">#</use>
350 let combined: Array<{ type_: string; data: Comment | Post }> = [];
351 let comments = this.state.comments.map(e => {
352 return { type_: 'comments', data: e };
354 let posts = this.state.posts.map(e => {
355 return { type_: 'posts', data: e };
358 combined.push(...comments);
359 combined.push(...posts);
362 if (this.state.sort == SortType.New) {
363 combined.sort((a, b) => b.data.published.localeCompare(a.data.published));
365 combined.sort((a, b) => b.data.score - a.data.score);
372 {i.type_ == 'posts' ? (
374 post={i.data as Post}
375 admins={this.state.admins}
377 enableDownvotes={this.state.site.enable_downvotes}
378 enableNsfw={this.state.site.enable_nsfw}
382 nodes={[{ comment: i.data as Comment }]}
383 admins={this.state.admins}
386 enableDownvotes={this.state.site.enable_downvotes}
399 nodes={commentsToFlatNodes(this.state.comments)}
400 admins={this.state.admins}
403 enableDownvotes={this.state.site.enable_downvotes}
412 {this.state.posts.map(post => (
415 admins={this.state.admins}
417 enableDownvotes={this.state.site.enable_downvotes}
418 enableNsfw={this.state.site.enable_nsfw}
426 let user = this.state.user;
429 <div class="card border-secondary mb-3">
430 <div class="card-body">
432 <ul class="list-inline mb-0">
433 <li className="list-inline-item">
434 <UserListing user={user} realLink />
437 <li className="list-inline-item badge badge-danger">
444 {i18n.t('joined')} <MomentTime data={user} showAgo />
446 <div class="table-responsive mt-1">
447 <table class="table table-bordered table-sm mt-2 mb-0">
450 <td class="text-center" colSpan={2}>
451 {i18n.t('number_of_points', {
452 count: user.post_score + user.comment_score,
460 {i18n.t('number_of_points', { count: user.post_score })}
464 {i18n.t('number_of_posts', { count: user.number_of_posts })}
470 {i18n.t('number_of_points', { count: user.comment_score })}
474 {i18n.t('number_of_comments', {
475 count: user.number_of_comments,
481 {this.isCurrentUser ? (
483 class="btn btn-block btn-secondary mt-3"
484 onClick={linkEvent(this, this.handleLogoutClick)}
491 className={`btn btn-block btn-secondary mt-3 ${
492 !this.state.user.matrix_user_id && 'disabled'
496 href={`https://matrix.to/#/${this.state.user.matrix_user_id}`}
498 {i18n.t('send_secure_message')}
501 class="btn btn-block btn-secondary mt-3"
502 to={`/create_private_message?recipient_id=${this.state.user.id}`}
504 {i18n.t('send_message')}
517 <div class="card border-secondary mb-3">
518 <div class="card-body">
519 <h5>{i18n.t('settings')}</h5>
520 <form onSubmit={linkEvent(this, this.handleUserSettingsSubmit)}>
521 <div class="form-group">
522 <label>{i18n.t('avatar')}</label>
523 <form class="d-inline">
525 htmlFor="file-upload"
526 class="pointer ml-4 text-muted small font-weight-bold"
528 {!this.state.userSettingsForm.avatar ? (
529 <span class="btn btn-sm btn-secondary">
530 {i18n.t('upload_avatar')}
536 src={this.state.userSettingsForm.avatar}
537 class="rounded-circle"
544 accept="image/*,video/*"
547 disabled={!UserService.Instance.user}
548 onChange={linkEvent(this, this.handleImageUpload)}
552 <div class="form-group">
553 <label>{i18n.t('language')}</label>
555 value={this.state.userSettingsForm.lang}
556 onChange={linkEvent(this, this.handleUserSettingsLangChange)}
557 class="ml-2 custom-select custom-select-sm w-auto"
559 <option disabled>{i18n.t('language')}</option>
560 <option value="browser">{i18n.t('browser_default')}</option>
561 <option disabled>──</option>
562 {languages.map(lang => (
563 <option value={lang.code}>{lang.name}</option>
567 <div class="form-group">
568 <label>{i18n.t('theme')}</label>
570 value={this.state.userSettingsForm.theme}
571 onChange={linkEvent(this, this.handleUserSettingsThemeChange)}
572 class="ml-2 custom-select custom-select-sm w-auto"
574 <option disabled>{i18n.t('theme')}</option>
575 {themes.map(theme => (
576 <option value={theme}>{theme}</option>
580 <form className="form-group">
582 <div class="mr-2">{i18n.t('sort_type')}</div>
585 type_={this.state.userSettingsForm.default_listing_type}
586 onChange={this.handleUserSettingsListingTypeChange}
589 <form className="form-group">
591 <div class="mr-2">{i18n.t('type')}</div>
594 sort={this.state.userSettingsForm.default_sort_type}
595 onChange={this.handleUserSettingsSortTypeChange}
598 <div class="form-group row">
599 <label class="col-lg-3 col-form-label" htmlFor="user-email">
602 <div class="col-lg-9">
607 placeholder={i18n.t('optional')}
608 value={this.state.userSettingsForm.email}
611 this.handleUserSettingsEmailChange
617 <div class="form-group row">
618 <label class="col-lg-5 col-form-label">
620 href="https://about.riot.im/"
624 {i18n.t('matrix_user_id')}
627 <div class="col-lg-7">
631 placeholder="@user:example.com"
632 value={this.state.userSettingsForm.matrix_user_id}
635 this.handleUserSettingsMatrixUserIdChange
641 <div class="form-group row">
642 <label class="col-lg-5 col-form-label" htmlFor="user-password">
643 {i18n.t('new_password')}
645 <div class="col-lg-7">
650 value={this.state.userSettingsForm.new_password}
651 autoComplete="new-password"
654 this.handleUserSettingsNewPasswordChange
659 <div class="form-group row">
661 class="col-lg-5 col-form-label"
662 htmlFor="user-verify-password"
664 {i18n.t('verify_password')}
666 <div class="col-lg-7">
669 id="user-verify-password"
671 value={this.state.userSettingsForm.new_password_verify}
672 autoComplete="new-password"
675 this.handleUserSettingsNewPasswordVerifyChange
680 <div class="form-group row">
682 class="col-lg-5 col-form-label"
683 htmlFor="user-old-password"
685 {i18n.t('old_password')}
687 <div class="col-lg-7">
690 id="user-old-password"
692 value={this.state.userSettingsForm.old_password}
693 autoComplete="new-password"
696 this.handleUserSettingsOldPasswordChange
701 {this.state.site.enable_nsfw && (
702 <div class="form-group">
703 <div class="form-check">
705 class="form-check-input"
708 checked={this.state.userSettingsForm.show_nsfw}
711 this.handleUserSettingsShowNsfwChange
714 <label class="form-check-label" htmlFor="user-show-nsfw">
715 {i18n.t('show_nsfw')}
720 <div class="form-group">
721 <div class="form-check">
723 class="form-check-input"
724 id="user-show-avatars"
726 checked={this.state.userSettingsForm.show_avatars}
729 this.handleUserSettingsShowAvatarsChange
732 <label class="form-check-label" htmlFor="user-show-avatars">
733 {i18n.t('show_avatars')}
737 <div class="form-group">
738 <div class="form-check">
740 class="form-check-input"
741 id="user-send-notifications-to-email"
743 disabled={!this.state.user.email}
745 this.state.userSettingsForm.send_notifications_to_email
749 this.handleUserSettingsSendNotificationsToEmailChange
753 class="form-check-label"
754 htmlFor="user-send-notifications-to-email"
756 {i18n.t('send_notifications_to_email')}
760 <div class="form-group">
761 <button type="submit" class="btn btn-block btn-secondary mr-4">
762 {this.state.userSettingsLoading ? (
763 <svg class="icon icon-spinner spin">
764 <use xlinkHref="#icon-spinner"></use>
767 capitalizeFirstLetter(i18n.t('save'))
772 <div class="form-group mb-0">
774 class="btn btn-block btn-danger"
777 this.handleDeleteAccountShowConfirmToggle
780 {i18n.t('delete_account')}
782 {this.state.deleteAccountShowConfirm && (
784 <div class="my-2 alert alert-danger" role="alert">
785 {i18n.t('delete_account_confirm')}
789 value={this.state.deleteAccountForm.password}
790 autoComplete="new-password"
793 this.handleDeleteAccountPasswordChange
795 class="form-control my-2"
798 class="btn btn-danger mr-4"
799 disabled={!this.state.deleteAccountForm.password}
800 onClick={linkEvent(this, this.handleDeleteAccount)}
802 {this.state.deleteAccountLoading ? (
803 <svg class="icon icon-spinner spin">
804 <use xlinkHref="#icon-spinner"></use>
807 capitalizeFirstLetter(i18n.t('delete'))
811 class="btn btn-secondary"
814 this.handleDeleteAccountShowConfirmToggle
832 {this.state.moderates.length > 0 && (
833 <div class="card border-secondary mb-3">
834 <div class="card-body">
835 <h5>{i18n.t('moderates')}</h5>
836 <ul class="list-unstyled mb-0">
837 {this.state.moderates.map(community => (
839 <Link to={`/c/${community.community_name}`}>
840 {community.community_name}
855 {this.state.follows.length > 0 && (
856 <div class="card border-secondary mb-3">
857 <div class="card-body">
858 <h5>{i18n.t('subscribed')}</h5>
859 <ul class="list-unstyled mb-0">
860 {this.state.follows.map(community => (
862 <Link to={`/c/${community.community_name}`}>
863 {community.community_name}
878 {this.state.page > 1 && (
880 class="btn btn-sm btn-secondary mr-1"
881 onClick={linkEvent(this, this.prevPage)}
887 class="btn btn-sm btn-secondary"
888 onClick={linkEvent(this, this.nextPage)}
897 let viewStr = View[this.state.view].toLowerCase();
898 let sortStr = SortType[this.state.sort].toLowerCase();
899 this.props.history.push(
900 `/u/${this.state.user.name}/view/${viewStr}/sort/${sortStr}/page/${this.state.page}`
919 let form: GetUserDetailsForm = {
920 user_id: this.state.user_id,
921 username: this.state.username,
922 sort: SortType[this.state.sort],
923 saved_only: this.state.view == View.Saved,
924 page: this.state.page,
927 WebSocketService.Instance.getUserDetails(form);
930 handleSortChange(val: SortType) {
931 this.state.sort = val;
933 this.setState(this.state);
938 handleViewChange(i: User, event: any) {
939 i.state.view = Number(event.target.value);
946 handleUserSettingsShowNsfwChange(i: User, event: any) {
947 i.state.userSettingsForm.show_nsfw = event.target.checked;
951 handleUserSettingsShowAvatarsChange(i: User, event: any) {
952 i.state.userSettingsForm.show_avatars = event.target.checked;
953 UserService.Instance.user.show_avatars = event.target.checked; // Just for instant updates
957 handleUserSettingsSendNotificationsToEmailChange(i: User, event: any) {
958 i.state.userSettingsForm.send_notifications_to_email = event.target.checked;
962 handleUserSettingsThemeChange(i: User, event: any) {
963 i.state.userSettingsForm.theme = event.target.value;
964 setTheme(event.target.value, true);
968 handleUserSettingsLangChange(i: User, event: any) {
969 i.state.userSettingsForm.lang = event.target.value;
970 i18n.changeLanguage(i.state.userSettingsForm.lang);
974 handleUserSettingsSortTypeChange(val: SortType) {
975 this.state.userSettingsForm.default_sort_type = val;
976 this.setState(this.state);
979 handleUserSettingsListingTypeChange(val: ListingType) {
980 this.state.userSettingsForm.default_listing_type = val;
981 this.setState(this.state);
984 handleUserSettingsEmailChange(i: User, event: any) {
985 i.state.userSettingsForm.email = event.target.value;
986 if (i.state.userSettingsForm.email == '' && !i.state.user.email) {
987 i.state.userSettingsForm.email = undefined;
992 handleUserSettingsMatrixUserIdChange(i: User, event: any) {
993 i.state.userSettingsForm.matrix_user_id = event.target.value;
995 i.state.userSettingsForm.matrix_user_id == '' &&
996 !i.state.user.matrix_user_id
998 i.state.userSettingsForm.matrix_user_id = undefined;
1000 i.setState(i.state);
1003 handleUserSettingsNewPasswordChange(i: User, event: any) {
1004 i.state.userSettingsForm.new_password = event.target.value;
1005 if (i.state.userSettingsForm.new_password == '') {
1006 i.state.userSettingsForm.new_password = undefined;
1008 i.setState(i.state);
1011 handleUserSettingsNewPasswordVerifyChange(i: User, event: any) {
1012 i.state.userSettingsForm.new_password_verify = event.target.value;
1013 if (i.state.userSettingsForm.new_password_verify == '') {
1014 i.state.userSettingsForm.new_password_verify = undefined;
1016 i.setState(i.state);
1019 handleUserSettingsOldPasswordChange(i: User, event: any) {
1020 i.state.userSettingsForm.old_password = event.target.value;
1021 if (i.state.userSettingsForm.old_password == '') {
1022 i.state.userSettingsForm.old_password = undefined;
1024 i.setState(i.state);
1027 handleImageUpload(i: User, event: any) {
1028 event.preventDefault();
1029 let file = event.target.files[0];
1030 const imageUploadUrl = `/pictrs/image`;
1031 const formData = new FormData();
1032 formData.append('images[]', file);
1034 i.state.avatarLoading = true;
1035 i.setState(i.state);
1037 fetch(imageUploadUrl, {
1041 .then(res => res.json())
1043 console.log('pictrs upload:');
1045 if (res.msg == 'ok') {
1046 let hash = res.files[0].file;
1047 let url = `${window.location.origin}/pictrs/image/${hash}`;
1048 i.state.userSettingsForm.avatar = url;
1049 i.state.avatarLoading = false;
1050 i.setState(i.state);
1052 i.state.avatarLoading = false;
1053 i.setState(i.state);
1054 toast(JSON.stringify(res), 'danger');
1058 i.state.avatarLoading = false;
1059 i.setState(i.state);
1060 toast(error, 'danger');
1064 handleUserSettingsSubmit(i: User, event: any) {
1065 event.preventDefault();
1066 i.state.userSettingsLoading = true;
1067 i.setState(i.state);
1069 WebSocketService.Instance.saveUserSettings(i.state.userSettingsForm);
1072 handleDeleteAccountShowConfirmToggle(i: User, event: any) {
1073 event.preventDefault();
1074 i.state.deleteAccountShowConfirm = !i.state.deleteAccountShowConfirm;
1075 i.setState(i.state);
1078 handleDeleteAccountPasswordChange(i: User, event: any) {
1079 i.state.deleteAccountForm.password = event.target.value;
1080 i.setState(i.state);
1083 handleLogoutClick(i: User) {
1084 UserService.Instance.logout();
1085 i.context.router.history.push('/');
1088 handleDeleteAccount(i: User, event: any) {
1089 event.preventDefault();
1090 i.state.deleteAccountLoading = true;
1091 i.setState(i.state);
1093 WebSocketService.Instance.deleteAccount(i.state.deleteAccountForm);
1096 parseMessage(msg: WebSocketJsonResponse) {
1098 let res = wsJsonToRes(msg);
1100 toast(i18n.t(msg.error), 'danger');
1101 this.state.deleteAccountLoading = false;
1102 this.state.avatarLoading = false;
1103 this.state.userSettingsLoading = false;
1104 if (msg.error == 'couldnt_find_that_username_or_email') {
1105 this.context.router.history.push('/');
1107 this.setState(this.state);
1109 } else if (msg.reconnect) {
1111 } else if (res.op == UserOperation.GetUserDetails) {
1112 let data = res.data as UserDetailsResponse;
1113 this.state.user = data.user;
1114 this.state.comments = data.comments;
1115 this.state.follows = data.follows;
1116 this.state.moderates = data.moderates;
1117 this.state.posts = data.posts;
1118 this.state.admins = data.admins;
1119 this.state.loading = false;
1120 if (this.isCurrentUser) {
1121 this.state.userSettingsForm.show_nsfw =
1122 UserService.Instance.user.show_nsfw;
1123 this.state.userSettingsForm.theme = UserService.Instance.user.theme
1124 ? UserService.Instance.user.theme
1126 this.state.userSettingsForm.default_sort_type =
1127 UserService.Instance.user.default_sort_type;
1128 this.state.userSettingsForm.default_listing_type =
1129 UserService.Instance.user.default_listing_type;
1130 this.state.userSettingsForm.lang = UserService.Instance.user.lang;
1131 this.state.userSettingsForm.avatar = UserService.Instance.user.avatar;
1132 this.state.userSettingsForm.email = this.state.user.email;
1133 this.state.userSettingsForm.send_notifications_to_email = this.state.user.send_notifications_to_email;
1134 this.state.userSettingsForm.show_avatars =
1135 UserService.Instance.user.show_avatars;
1136 this.state.userSettingsForm.matrix_user_id = this.state.user.matrix_user_id;
1138 document.title = `/u/${this.state.user.name} - ${this.state.site.name}`;
1139 window.scrollTo(0, 0);
1140 this.setState(this.state);
1142 } else if (res.op == UserOperation.EditComment) {
1143 let data = res.data as CommentResponse;
1144 editCommentRes(data, this.state.comments);
1145 this.setState(this.state);
1146 } else if (res.op == UserOperation.CreateComment) {
1147 let data = res.data as CommentResponse;
1149 UserService.Instance.user &&
1150 data.comment.creator_id == UserService.Instance.user.id
1152 toast(i18n.t('reply_sent'));
1154 } else if (res.op == UserOperation.SaveComment) {
1155 let data = res.data as CommentResponse;
1156 saveCommentRes(data, this.state.comments);
1157 this.setState(this.state);
1158 } else if (res.op == UserOperation.CreateCommentLike) {
1159 let data = res.data as CommentResponse;
1160 createCommentLikeRes(data, this.state.comments);
1161 this.setState(this.state);
1162 } else if (res.op == UserOperation.CreatePostLike) {
1163 let data = res.data as PostResponse;
1164 createPostLikeFindRes(data, this.state.posts);
1165 this.setState(this.state);
1166 } else if (res.op == UserOperation.BanUser) {
1167 let data = res.data as BanUserResponse;
1169 .filter(c => c.creator_id == data.user.id)
1170 .forEach(c => (c.banned = data.banned));
1172 .filter(c => c.creator_id == data.user.id)
1173 .forEach(c => (c.banned = data.banned));
1174 this.setState(this.state);
1175 } else if (res.op == UserOperation.AddAdmin) {
1176 let data = res.data as AddAdminResponse;
1177 this.state.admins = data.admins;
1178 this.setState(this.state);
1179 } else if (res.op == UserOperation.SaveUserSettings) {
1180 let data = res.data as LoginResponse;
1181 this.state = this.emptyState;
1182 this.state.userSettingsLoading = false;
1183 this.setState(this.state);
1184 UserService.Instance.login(data);
1185 } else if (res.op == UserOperation.DeleteAccount) {
1186 this.state.deleteAccountLoading = false;
1187 this.state.deleteAccountShowConfirm = false;
1188 this.setState(this.state);
1189 this.context.router.history.push('/');
1190 } else if (res.op == UserOperation.GetSite) {
1191 let data = res.data as GetSiteResponse;
1192 this.state.site = data.site;
1193 this.setState(this.state);