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';
51 import moment from 'moment';
64 follows: Array<CommunityUser>;
65 moderates: Array<CommunityUser>;
66 comments: Array<Comment>;
69 admins: Array<UserView>;
74 avatarLoading: boolean;
75 userSettingsForm: UserSettingsForm;
76 userSettingsLoading: boolean;
77 deleteAccountLoading: boolean;
78 deleteAccountShowConfirm: boolean;
79 deleteAccountForm: DeleteAccountForm;
83 export class User extends Component<any, UserState> {
84 private subscription: Subscription;
85 private emptyState: UserState = {
90 number_of_posts: null,
92 number_of_comments: null,
97 send_notifications_to_email: null,
109 avatarLoading: false,
110 view: this.getViewFromProps(this.props),
111 sort: this.getSortTypeFromProps(this.props),
112 page: this.getPageFromProps(this.props),
116 default_sort_type: null,
117 default_listing_type: null,
120 send_notifications_to_email: null,
123 userSettingsLoading: null,
124 deleteAccountLoading: null,
125 deleteAccountShowConfirm: false,
132 creator_id: undefined,
133 published: undefined,
134 creator_name: undefined,
135 number_of_users: undefined,
136 number_of_posts: undefined,
137 number_of_comments: undefined,
138 number_of_communities: undefined,
139 enable_downvotes: undefined,
140 open_registration: undefined,
141 enable_nsfw: undefined,
145 constructor(props: any, context: any) {
146 super(props, context);
148 this.state = this.emptyState;
149 this.handleSortChange = this.handleSortChange.bind(this);
150 this.handleUserSettingsSortTypeChange = this.handleUserSettingsSortTypeChange.bind(
153 this.handleUserSettingsListingTypeChange = this.handleUserSettingsListingTypeChange.bind(
157 this.state.user_id = Number(this.props.match.params.id);
158 this.state.username = this.props.match.params.username;
160 this.subscription = WebSocketService.Instance.subject
161 .pipe(retryWhen(errors => errors.pipe(delay(3000), take(10))))
163 msg => this.parseMessage(msg),
164 err => console.error(err),
165 () => console.log('complete')
169 WebSocketService.Instance.getSite();
172 get isCurrentUser() {
174 UserService.Instance.user &&
175 UserService.Instance.user.id == this.state.user.id
179 getViewFromProps(props: any): View {
180 return props.match.params.view
181 ? View[capitalizeFirstLetter(props.match.params.view)]
185 getSortTypeFromProps(props: any): SortType {
186 return props.match.params.sort
187 ? routeSortTypeToEnum(props.match.params.sort)
191 getPageFromProps(props: any): number {
192 return props.match.params.page ? Number(props.match.params.page) : 1;
195 componentWillUnmount() {
196 this.subscription.unsubscribe();
199 // Necessary for back button for some reason
200 componentWillReceiveProps(nextProps: any) {
202 nextProps.history.action == 'POP' ||
203 nextProps.history.action == 'PUSH'
205 this.state.view = this.getViewFromProps(nextProps);
206 this.state.sort = this.getSortTypeFromProps(nextProps);
207 this.state.page = this.getPageFromProps(nextProps);
208 this.setState(this.state);
213 componentDidUpdate(lastProps: any, _lastState: UserState, _snapshot: any) {
214 // Necessary if you are on a post and you click another post (same route)
216 lastProps.location.pathname.split('/')[2] !==
217 lastProps.history.location.pathname.split('/')[2]
219 // Couldnt get a refresh working. This does for now.
226 <div class="container">
227 {this.state.loading ? (
229 <svg class="icon icon-spinner spin">
230 <use xlinkHref="#icon-spinner"></use>
235 <div class="col-12 col-md-8">
237 {this.state.user.avatar && showAvatars() && (
241 src={this.state.user.avatar}
242 class="rounded-circle mr-2"
245 <span>/u/{this.state.user.name}</span>
248 {this.state.view == View.Overview && this.overview()}
249 {this.state.view == View.Comments && this.comments()}
250 {this.state.view == View.Posts && this.posts()}
251 {this.state.view == View.Saved && this.overview()}
254 <div class="col-12 col-md-4">
256 {this.isCurrentUser && this.userSettings()}
268 <div class="btn-group btn-group-toggle">
270 className={`btn btn-sm btn-secondary pointer btn-outline-light
271 ${this.state.view == View.Overview && 'active'}
276 value={View.Overview}
277 checked={this.state.view == View.Overview}
278 onChange={linkEvent(this, this.handleViewChange)}
283 className={`btn btn-sm btn-secondary pointer btn-outline-light
284 ${this.state.view == View.Comments && 'active'}
289 value={View.Comments}
290 checked={this.state.view == View.Comments}
291 onChange={linkEvent(this, this.handleViewChange)}
296 className={`btn btn-sm btn-secondary pointer btn-outline-light
297 ${this.state.view == View.Posts && 'active'}
303 checked={this.state.view == View.Posts}
304 onChange={linkEvent(this, this.handleViewChange)}
309 className={`btn btn-sm btn-secondary pointer btn-outline-light
310 ${this.state.view == View.Saved && 'active'}
316 checked={this.state.view == View.Saved}
317 onChange={linkEvent(this, this.handleViewChange)}
327 <div className="mb-2">
328 <span class="mr-3">{this.viewRadios()}</span>
330 sort={this.state.sort}
331 onChange={this.handleSortChange}
335 href={`/feeds/u/${this.state.username}.xml?sort=${
336 SortType[this.state.sort]
342 <svg class="icon mx-2 text-muted small">
343 <use xlinkHref="#icon-rss">#</use>
351 let combined: Array<{ type_: string; data: Comment | Post }> = [];
352 let comments = this.state.comments.map(e => {
353 return { type_: 'comments', data: e };
355 let posts = this.state.posts.map(e => {
356 return { type_: 'posts', data: e };
359 combined.push(...comments);
360 combined.push(...posts);
363 if (this.state.sort == SortType.New) {
364 combined.sort((a, b) => b.data.published.localeCompare(a.data.published));
366 combined.sort((a, b) => b.data.score - a.data.score);
373 {i.type_ == 'posts' ? (
375 post={i.data as Post}
376 admins={this.state.admins}
378 enableDownvotes={this.state.site.enable_downvotes}
379 enableNsfw={this.state.site.enable_nsfw}
383 nodes={[{ comment: i.data as Comment }]}
384 admins={this.state.admins}
387 enableDownvotes={this.state.site.enable_downvotes}
400 nodes={commentsToFlatNodes(this.state.comments)}
401 admins={this.state.admins}
404 enableDownvotes={this.state.site.enable_downvotes}
413 {this.state.posts.map(post => (
416 admins={this.state.admins}
418 enableDownvotes={this.state.site.enable_downvotes}
419 enableNsfw={this.state.site.enable_nsfw}
427 let user = this.state.user;
430 <div class="card border-secondary mb-3">
431 <div class="card-body">
433 <ul class="list-inline mb-0">
434 <li className="list-inline-item">
435 <UserListing user={user} realLink />
438 <li className="list-inline-item badge badge-danger">
444 <div className="d-flex align-items-center mb-2">
446 <use xlinkHref="#icon-cake"></use>
448 <span className="ml-2">
449 {i18n.t('cake_day_title')}{' '}
450 {moment.utc(user.published).local().format('MMM DD, YYYY')}
454 {i18n.t('joined')} <MomentTime data={user} showAgo />
456 <div class="table-responsive mt-1">
457 <table class="table table-bordered table-sm mt-2 mb-0">
460 <td class="text-center" colSpan={2}>
461 {i18n.t('number_of_points', {
462 count: user.post_score + user.comment_score,
470 {i18n.t('number_of_points', { count: user.post_score })}
474 {i18n.t('number_of_posts', { count: user.number_of_posts })}
480 {i18n.t('number_of_points', { count: user.comment_score })}
484 {i18n.t('number_of_comments', {
485 count: user.number_of_comments,
491 {this.isCurrentUser ? (
493 class="btn btn-block btn-secondary mt-3"
494 onClick={linkEvent(this, this.handleLogoutClick)}
501 className={`btn btn-block btn-secondary mt-3 ${
502 !this.state.user.matrix_user_id && 'disabled'
506 href={`https://matrix.to/#/${this.state.user.matrix_user_id}`}
508 {i18n.t('send_secure_message')}
511 class="btn btn-block btn-secondary mt-3"
512 to={`/create_private_message?recipient_id=${this.state.user.id}`}
514 {i18n.t('send_message')}
527 <div class="card border-secondary mb-3">
528 <div class="card-body">
529 <h5>{i18n.t('settings')}</h5>
530 <form onSubmit={linkEvent(this, this.handleUserSettingsSubmit)}>
531 <div class="form-group">
532 <label>{i18n.t('avatar')}</label>
533 <form class="d-inline">
535 htmlFor="file-upload"
536 class="pointer ml-4 text-muted small font-weight-bold"
538 {!this.state.userSettingsForm.avatar ? (
539 <span class="btn btn-sm btn-secondary">
540 {i18n.t('upload_avatar')}
546 src={this.state.userSettingsForm.avatar}
547 class="rounded-circle"
554 accept="image/*,video/*"
557 disabled={!UserService.Instance.user}
558 onChange={linkEvent(this, this.handleImageUpload)}
562 <div class="form-group">
563 <label>{i18n.t('language')}</label>
565 value={this.state.userSettingsForm.lang}
566 onChange={linkEvent(this, this.handleUserSettingsLangChange)}
567 class="ml-2 custom-select custom-select-sm w-auto"
569 <option disabled>{i18n.t('language')}</option>
570 <option value="browser">{i18n.t('browser_default')}</option>
571 <option disabled>──</option>
572 {languages.map(lang => (
573 <option value={lang.code}>{lang.name}</option>
577 <div class="form-group">
578 <label>{i18n.t('theme')}</label>
580 value={this.state.userSettingsForm.theme}
581 onChange={linkEvent(this, this.handleUserSettingsThemeChange)}
582 class="ml-2 custom-select custom-select-sm w-auto"
584 <option disabled>{i18n.t('theme')}</option>
585 {themes.map(theme => (
586 <option value={theme}>{theme}</option>
590 <form className="form-group">
592 <div class="mr-2">{i18n.t('sort_type')}</div>
595 type_={this.state.userSettingsForm.default_listing_type}
596 onChange={this.handleUserSettingsListingTypeChange}
599 <form className="form-group">
601 <div class="mr-2">{i18n.t('type')}</div>
604 sort={this.state.userSettingsForm.default_sort_type}
605 onChange={this.handleUserSettingsSortTypeChange}
608 <div class="form-group row">
609 <label class="col-lg-3 col-form-label" htmlFor="user-email">
612 <div class="col-lg-9">
617 placeholder={i18n.t('optional')}
618 value={this.state.userSettingsForm.email}
621 this.handleUserSettingsEmailChange
627 <div class="form-group row">
628 <label class="col-lg-5 col-form-label">
630 href="https://about.riot.im/"
634 {i18n.t('matrix_user_id')}
637 <div class="col-lg-7">
641 placeholder="@user:example.com"
642 value={this.state.userSettingsForm.matrix_user_id}
645 this.handleUserSettingsMatrixUserIdChange
651 <div class="form-group row">
652 <label class="col-lg-5 col-form-label" htmlFor="user-password">
653 {i18n.t('new_password')}
655 <div class="col-lg-7">
660 value={this.state.userSettingsForm.new_password}
661 autoComplete="new-password"
664 this.handleUserSettingsNewPasswordChange
669 <div class="form-group row">
671 class="col-lg-5 col-form-label"
672 htmlFor="user-verify-password"
674 {i18n.t('verify_password')}
676 <div class="col-lg-7">
679 id="user-verify-password"
681 value={this.state.userSettingsForm.new_password_verify}
682 autoComplete="new-password"
685 this.handleUserSettingsNewPasswordVerifyChange
690 <div class="form-group row">
692 class="col-lg-5 col-form-label"
693 htmlFor="user-old-password"
695 {i18n.t('old_password')}
697 <div class="col-lg-7">
700 id="user-old-password"
702 value={this.state.userSettingsForm.old_password}
703 autoComplete="new-password"
706 this.handleUserSettingsOldPasswordChange
711 {this.state.site.enable_nsfw && (
712 <div class="form-group">
713 <div class="form-check">
715 class="form-check-input"
718 checked={this.state.userSettingsForm.show_nsfw}
721 this.handleUserSettingsShowNsfwChange
724 <label class="form-check-label" htmlFor="user-show-nsfw">
725 {i18n.t('show_nsfw')}
730 <div class="form-group">
731 <div class="form-check">
733 class="form-check-input"
734 id="user-show-avatars"
736 checked={this.state.userSettingsForm.show_avatars}
739 this.handleUserSettingsShowAvatarsChange
742 <label class="form-check-label" htmlFor="user-show-avatars">
743 {i18n.t('show_avatars')}
747 <div class="form-group">
748 <div class="form-check">
750 class="form-check-input"
751 id="user-send-notifications-to-email"
753 disabled={!this.state.user.email}
755 this.state.userSettingsForm.send_notifications_to_email
759 this.handleUserSettingsSendNotificationsToEmailChange
763 class="form-check-label"
764 htmlFor="user-send-notifications-to-email"
766 {i18n.t('send_notifications_to_email')}
770 <div class="form-group">
771 <button type="submit" class="btn btn-block btn-secondary mr-4">
772 {this.state.userSettingsLoading ? (
773 <svg class="icon icon-spinner spin">
774 <use xlinkHref="#icon-spinner"></use>
777 capitalizeFirstLetter(i18n.t('save'))
782 <div class="form-group mb-0">
784 class="btn btn-block btn-danger"
787 this.handleDeleteAccountShowConfirmToggle
790 {i18n.t('delete_account')}
792 {this.state.deleteAccountShowConfirm && (
794 <div class="my-2 alert alert-danger" role="alert">
795 {i18n.t('delete_account_confirm')}
799 value={this.state.deleteAccountForm.password}
800 autoComplete="new-password"
803 this.handleDeleteAccountPasswordChange
805 class="form-control my-2"
808 class="btn btn-danger mr-4"
809 disabled={!this.state.deleteAccountForm.password}
810 onClick={linkEvent(this, this.handleDeleteAccount)}
812 {this.state.deleteAccountLoading ? (
813 <svg class="icon icon-spinner spin">
814 <use xlinkHref="#icon-spinner"></use>
817 capitalizeFirstLetter(i18n.t('delete'))
821 class="btn btn-secondary"
824 this.handleDeleteAccountShowConfirmToggle
842 {this.state.moderates.length > 0 && (
843 <div class="card border-secondary mb-3">
844 <div class="card-body">
845 <h5>{i18n.t('moderates')}</h5>
846 <ul class="list-unstyled mb-0">
847 {this.state.moderates.map(community => (
849 <Link to={`/c/${community.community_name}`}>
850 {community.community_name}
865 {this.state.follows.length > 0 && (
866 <div class="card border-secondary mb-3">
867 <div class="card-body">
868 <h5>{i18n.t('subscribed')}</h5>
869 <ul class="list-unstyled mb-0">
870 {this.state.follows.map(community => (
872 <Link to={`/c/${community.community_name}`}>
873 {community.community_name}
888 {this.state.page > 1 && (
890 class="btn btn-sm btn-secondary mr-1"
891 onClick={linkEvent(this, this.prevPage)}
897 class="btn btn-sm btn-secondary"
898 onClick={linkEvent(this, this.nextPage)}
907 let viewStr = View[this.state.view].toLowerCase();
908 let sortStr = SortType[this.state.sort].toLowerCase();
909 this.props.history.push(
910 `/u/${this.state.user.name}/view/${viewStr}/sort/${sortStr}/page/${this.state.page}`
929 let form: GetUserDetailsForm = {
930 user_id: this.state.user_id,
931 username: this.state.username,
932 sort: SortType[this.state.sort],
933 saved_only: this.state.view == View.Saved,
934 page: this.state.page,
937 WebSocketService.Instance.getUserDetails(form);
940 handleSortChange(val: SortType) {
941 this.state.sort = val;
943 this.setState(this.state);
948 handleViewChange(i: User, event: any) {
949 i.state.view = Number(event.target.value);
956 handleUserSettingsShowNsfwChange(i: User, event: any) {
957 i.state.userSettingsForm.show_nsfw = event.target.checked;
961 handleUserSettingsShowAvatarsChange(i: User, event: any) {
962 i.state.userSettingsForm.show_avatars = event.target.checked;
963 UserService.Instance.user.show_avatars = event.target.checked; // Just for instant updates
967 handleUserSettingsSendNotificationsToEmailChange(i: User, event: any) {
968 i.state.userSettingsForm.send_notifications_to_email = event.target.checked;
972 handleUserSettingsThemeChange(i: User, event: any) {
973 i.state.userSettingsForm.theme = event.target.value;
974 setTheme(event.target.value, true);
978 handleUserSettingsLangChange(i: User, event: any) {
979 i.state.userSettingsForm.lang = event.target.value;
980 i18n.changeLanguage(i.state.userSettingsForm.lang);
984 handleUserSettingsSortTypeChange(val: SortType) {
985 this.state.userSettingsForm.default_sort_type = val;
986 this.setState(this.state);
989 handleUserSettingsListingTypeChange(val: ListingType) {
990 this.state.userSettingsForm.default_listing_type = val;
991 this.setState(this.state);
994 handleUserSettingsEmailChange(i: User, event: any) {
995 i.state.userSettingsForm.email = event.target.value;
996 if (i.state.userSettingsForm.email == '' && !i.state.user.email) {
997 i.state.userSettingsForm.email = undefined;
1002 handleUserSettingsMatrixUserIdChange(i: User, event: any) {
1003 i.state.userSettingsForm.matrix_user_id = event.target.value;
1005 i.state.userSettingsForm.matrix_user_id == '' &&
1006 !i.state.user.matrix_user_id
1008 i.state.userSettingsForm.matrix_user_id = undefined;
1010 i.setState(i.state);
1013 handleUserSettingsNewPasswordChange(i: User, event: any) {
1014 i.state.userSettingsForm.new_password = event.target.value;
1015 if (i.state.userSettingsForm.new_password == '') {
1016 i.state.userSettingsForm.new_password = undefined;
1018 i.setState(i.state);
1021 handleUserSettingsNewPasswordVerifyChange(i: User, event: any) {
1022 i.state.userSettingsForm.new_password_verify = event.target.value;
1023 if (i.state.userSettingsForm.new_password_verify == '') {
1024 i.state.userSettingsForm.new_password_verify = undefined;
1026 i.setState(i.state);
1029 handleUserSettingsOldPasswordChange(i: User, event: any) {
1030 i.state.userSettingsForm.old_password = event.target.value;
1031 if (i.state.userSettingsForm.old_password == '') {
1032 i.state.userSettingsForm.old_password = undefined;
1034 i.setState(i.state);
1037 handleImageUpload(i: User, event: any) {
1038 event.preventDefault();
1039 let file = event.target.files[0];
1040 const imageUploadUrl = `/pictrs/image`;
1041 const formData = new FormData();
1042 formData.append('images[]', file);
1044 i.state.avatarLoading = true;
1045 i.setState(i.state);
1047 fetch(imageUploadUrl, {
1051 .then(res => res.json())
1053 console.log('pictrs upload:');
1055 if (res.msg == 'ok') {
1056 let hash = res.files[0].file;
1057 let url = `${window.location.origin}/pictrs/image/${hash}`;
1058 i.state.userSettingsForm.avatar = url;
1059 i.state.avatarLoading = false;
1060 i.setState(i.state);
1062 i.state.avatarLoading = false;
1063 i.setState(i.state);
1064 toast(JSON.stringify(res), 'danger');
1068 i.state.avatarLoading = false;
1069 i.setState(i.state);
1070 toast(error, 'danger');
1074 handleUserSettingsSubmit(i: User, event: any) {
1075 event.preventDefault();
1076 i.state.userSettingsLoading = true;
1077 i.setState(i.state);
1079 WebSocketService.Instance.saveUserSettings(i.state.userSettingsForm);
1082 handleDeleteAccountShowConfirmToggle(i: User, event: any) {
1083 event.preventDefault();
1084 i.state.deleteAccountShowConfirm = !i.state.deleteAccountShowConfirm;
1085 i.setState(i.state);
1088 handleDeleteAccountPasswordChange(i: User, event: any) {
1089 i.state.deleteAccountForm.password = event.target.value;
1090 i.setState(i.state);
1093 handleLogoutClick(i: User) {
1094 UserService.Instance.logout();
1095 i.context.router.history.push('/');
1098 handleDeleteAccount(i: User, event: any) {
1099 event.preventDefault();
1100 i.state.deleteAccountLoading = true;
1101 i.setState(i.state);
1103 WebSocketService.Instance.deleteAccount(i.state.deleteAccountForm);
1106 parseMessage(msg: WebSocketJsonResponse) {
1108 let res = wsJsonToRes(msg);
1110 toast(i18n.t(msg.error), 'danger');
1111 this.state.deleteAccountLoading = false;
1112 this.state.avatarLoading = false;
1113 this.state.userSettingsLoading = false;
1114 if (msg.error == 'couldnt_find_that_username_or_email') {
1115 this.context.router.history.push('/');
1117 this.setState(this.state);
1119 } else if (msg.reconnect) {
1121 } else if (res.op == UserOperation.GetUserDetails) {
1122 let data = res.data as UserDetailsResponse;
1123 this.state.user = data.user;
1124 this.state.comments = data.comments;
1125 this.state.follows = data.follows;
1126 this.state.moderates = data.moderates;
1127 this.state.posts = data.posts;
1128 this.state.admins = data.admins;
1129 this.state.loading = false;
1130 if (this.isCurrentUser) {
1131 this.state.userSettingsForm.show_nsfw =
1132 UserService.Instance.user.show_nsfw;
1133 this.state.userSettingsForm.theme = UserService.Instance.user.theme
1134 ? UserService.Instance.user.theme
1136 this.state.userSettingsForm.default_sort_type =
1137 UserService.Instance.user.default_sort_type;
1138 this.state.userSettingsForm.default_listing_type =
1139 UserService.Instance.user.default_listing_type;
1140 this.state.userSettingsForm.lang = UserService.Instance.user.lang;
1141 this.state.userSettingsForm.avatar = UserService.Instance.user.avatar;
1142 this.state.userSettingsForm.email = this.state.user.email;
1143 this.state.userSettingsForm.send_notifications_to_email = this.state.user.send_notifications_to_email;
1144 this.state.userSettingsForm.show_avatars =
1145 UserService.Instance.user.show_avatars;
1146 this.state.userSettingsForm.matrix_user_id = this.state.user.matrix_user_id;
1148 document.title = `/u/${this.state.user.name} - ${this.state.site.name}`;
1149 window.scrollTo(0, 0);
1150 this.setState(this.state);
1152 } else if (res.op == UserOperation.EditComment) {
1153 let data = res.data as CommentResponse;
1154 editCommentRes(data, this.state.comments);
1155 this.setState(this.state);
1156 } else if (res.op == UserOperation.CreateComment) {
1157 let data = res.data as CommentResponse;
1159 UserService.Instance.user &&
1160 data.comment.creator_id == UserService.Instance.user.id
1162 toast(i18n.t('reply_sent'));
1164 } else if (res.op == UserOperation.SaveComment) {
1165 let data = res.data as CommentResponse;
1166 saveCommentRes(data, this.state.comments);
1167 this.setState(this.state);
1168 } else if (res.op == UserOperation.CreateCommentLike) {
1169 let data = res.data as CommentResponse;
1170 createCommentLikeRes(data, this.state.comments);
1171 this.setState(this.state);
1172 } else if (res.op == UserOperation.CreatePostLike) {
1173 let data = res.data as PostResponse;
1174 createPostLikeFindRes(data, this.state.posts);
1175 this.setState(this.state);
1176 } else if (res.op == UserOperation.BanUser) {
1177 let data = res.data as BanUserResponse;
1179 .filter(c => c.creator_id == data.user.id)
1180 .forEach(c => (c.banned = data.banned));
1182 .filter(c => c.creator_id == data.user.id)
1183 .forEach(c => (c.banned = data.banned));
1184 this.setState(this.state);
1185 } else if (res.op == UserOperation.AddAdmin) {
1186 let data = res.data as AddAdminResponse;
1187 this.state.admins = data.admins;
1188 this.setState(this.state);
1189 } else if (res.op == UserOperation.SaveUserSettings) {
1190 let data = res.data as LoginResponse;
1191 this.state = this.emptyState;
1192 this.state.userSettingsLoading = false;
1193 this.setState(this.state);
1194 UserService.Instance.login(data);
1195 } else if (res.op == UserOperation.DeleteAccount) {
1196 this.state.deleteAccountLoading = false;
1197 this.state.deleteAccountShowConfirm = false;
1198 this.setState(this.state);
1199 this.context.router.history.push('/');
1200 } else if (res.op == UserOperation.GetSite) {
1201 let data = res.data as GetSiteResponse;
1202 this.state.site = data.site;
1203 this.setState(this.state);