1 import { Component, linkEvent } from "inferno";
4 BlockCommunityResponse,
19 } from "lemmy-js-client";
20 import { Subscription } from "rxjs";
21 import { i18n, languages } from "../../i18next";
22 import { UserService, WebSocketService } from "../../services";
25 capitalizeFirstLetter,
51 import { HtmlTags } from "../common/html-tags";
52 import { Icon, Spinner } from "../common/icon";
53 import { ImageUploadForm } from "../common/image-upload-form";
54 import { ListingTypeSelect } from "../common/listing-type-select";
55 import { MarkdownTextArea } from "../common/markdown-textarea";
56 import { SortSelect } from "../common/sort-select";
57 import { CommunityLink } from "../community/community-link";
58 import { PersonListing } from "./person-listing";
62 Choices = require("choices.js");
65 interface SettingsState {
66 saveUserSettingsForm: SaveUserSettings;
67 changePasswordForm: ChangePassword;
68 saveUserSettingsLoading: boolean;
69 changePasswordLoading: boolean;
70 deleteAccountLoading: boolean;
71 deleteAccountShowConfirm: boolean;
72 deleteAccountForm: DeleteAccount;
73 personBlocks: PersonBlockView[];
74 blockPersonId: number;
75 blockPerson?: PersonViewSafe;
76 communityBlocks: CommunityBlockView[];
77 blockCommunityId: number;
78 blockCommunity?: CommunityView;
80 siteRes: GetSiteResponse;
84 export class Settings extends Component<any, SettingsState> {
85 private isoData = setIsoData(this.context);
86 private blockPersonChoices: any;
87 private blockCommunityChoices: any;
88 private subscription: Subscription;
89 private emptyState: SettingsState = {
90 saveUserSettingsForm: {
91 auth: authField(false),
95 new_password_verify: null,
97 auth: authField(false),
99 saveUserSettingsLoading: null,
100 changePasswordLoading: false,
101 deleteAccountLoading: null,
102 deleteAccountShowConfirm: false,
105 auth: authField(false),
111 currentTab: "settings",
112 siteRes: this.isoData.site_res,
116 constructor(props: any, context: any) {
117 super(props, context);
119 this.state = this.emptyState;
120 this.handleSortTypeChange = this.handleSortTypeChange.bind(this);
121 this.handleListingTypeChange = this.handleListingTypeChange.bind(this);
122 this.handleBioChange = this.handleBioChange.bind(this);
124 this.handleAvatarUpload = this.handleAvatarUpload.bind(this);
125 this.handleAvatarRemove = this.handleAvatarRemove.bind(this);
127 this.handleBannerUpload = this.handleBannerUpload.bind(this);
128 this.handleBannerRemove = this.handleBannerRemove.bind(this);
130 this.parseMessage = this.parseMessage.bind(this);
131 this.subscription = wsSubscribe(this.parseMessage);
136 async componentDidMount() {
138 this.state.themeList = await fetchThemeList();
139 this.setState(this.state);
142 componentWillUnmount() {
143 this.subscription.unsubscribe();
146 get documentTitle(): string {
147 return i18n.t("settings");
152 <div class="container">
155 title={this.documentTitle}
156 path={this.context.router.route.match.url}
157 description={this.documentTitle}
158 image={this.state.saveUserSettingsForm.avatar}
160 <ul class="nav nav-tabs mb-2">
161 <li class="nav-item">
163 class={`nav-link btn ${
164 this.state.currentTab == "settings" && "active"
167 { ctx: this, tab: "settings" },
174 <li class="nav-item">
176 class={`nav-link btn ${
177 this.state.currentTab == "blocks" && "active"
180 { ctx: this, tab: "blocks" },
188 {this.state.currentTab == "settings" && this.userSettings()}
189 {this.state.currentTab == "blocks" && this.blockCards()}
198 <div class="col-12 col-md-6">
199 <div class="card border-secondary mb-3">
200 <div class="card-body">{this.saveUserSettingsHtmlForm()}</div>
203 <div class="col-12 col-md-6">
204 <div class="card border-secondary mb-3">
205 <div class="card-body">{this.changePasswordHtmlForm()}</div>
215 <div class="col-12 col-md-6">
216 <div class="card border-secondary mb-3">
217 <div class="card-body">{this.blockUserCard()}</div>
220 <div class="col-12 col-md-6">
221 <div class="card border-secondary mb-3">
222 <div class="card-body">{this.blockCommunityCard()}</div>
229 changePasswordHtmlForm() {
232 <h5>{i18n.t("change_password")}</h5>
233 <form onSubmit={linkEvent(this, this.handleChangePasswordSubmit)}>
234 <div class="form-group row">
235 <label class="col-sm-5 col-form-label" htmlFor="user-password">
236 {i18n.t("new_password")}
238 <div class="col-sm-7">
243 value={this.state.changePasswordForm.new_password}
244 autoComplete="new-password"
246 onInput={linkEvent(this, this.handleNewPasswordChange)}
250 <div class="form-group row">
252 class="col-sm-5 col-form-label"
253 htmlFor="user-verify-password"
255 {i18n.t("verify_password")}
257 <div class="col-sm-7">
260 id="user-verify-password"
262 value={this.state.changePasswordForm.new_password_verify}
263 autoComplete="new-password"
265 onInput={linkEvent(this, this.handleNewPasswordVerifyChange)}
269 <div class="form-group row">
270 <label class="col-sm-5 col-form-label" htmlFor="user-old-password">
271 {i18n.t("old_password")}
273 <div class="col-sm-7">
276 id="user-old-password"
278 value={this.state.changePasswordForm.old_password}
279 autoComplete="new-password"
281 onInput={linkEvent(this, this.handleOldPasswordChange)}
285 <div class="form-group">
286 <button type="submit" class="btn btn-block btn-secondary mr-4">
287 {this.state.changePasswordLoading ? (
290 capitalizeFirstLetter(i18n.t("save"))
302 {this.blockUserForm()}
303 {this.blockedUsersList()}
311 <h5>{i18n.t("blocked_users")}</h5>
312 <ul class="list-unstyled mb-0">
313 {this.state.personBlocks.map(pb => (
316 <PersonListing person={pb.target} />
318 className="btn btn-sm"
320 { ctx: this, recipientId: pb.target.id },
321 this.handleUnblockPerson
323 data-tippy-content={i18n.t("unblock_user")}
325 <Icon icon="x" classes="icon-inline" />
337 <div class="form-group row">
338 <label class="col-md-4 col-form-label" htmlFor="block-person-filter">
339 {i18n.t("block_user")}
341 <div class="col-md-8">
344 id="block-person-filter"
345 value={this.state.blockPersonId}
347 <option value="0">—</option>
348 {this.state.blockPerson && (
349 <option value={this.state.blockPerson.person.id}>
350 {personSelectName(this.state.blockPerson)}
359 blockCommunityCard() {
362 {this.blockCommunityForm()}
363 {this.blockedCommunitiesList()}
368 blockedCommunitiesList() {
371 <h5>{i18n.t("blocked_communities")}</h5>
372 <ul class="list-unstyled mb-0">
373 {this.state.communityBlocks.map(cb => (
376 <CommunityLink community={cb.community} />
378 className="btn btn-sm"
380 { ctx: this, communityId: cb.community.id },
381 this.handleUnblockCommunity
383 data-tippy-content={i18n.t("unblock_community")}
385 <Icon icon="x" classes="icon-inline" />
395 blockCommunityForm() {
397 <div class="form-group row">
398 <label class="col-md-4 col-form-label" htmlFor="block-community-filter">
399 {i18n.t("block_community")}
401 <div class="col-md-8">
404 id="block-community-filter"
405 value={this.state.blockCommunityId}
407 <option value="0">—</option>
408 {this.state.blockCommunity && (
409 <option value={this.state.blockCommunity.community.id}>
410 {communitySelectName(this.state.blockCommunity)}
419 saveUserSettingsHtmlForm() {
422 <h5>{i18n.t("settings")}</h5>
423 <form onSubmit={linkEvent(this, this.handleSaveSettingsSubmit)}>
424 <div class="form-group row">
425 <label class="col-sm-5 col-form-label" htmlFor="display-name">
426 {i18n.t("display_name")}
428 <div class="col-sm-7">
433 placeholder={i18n.t("optional")}
434 value={this.state.saveUserSettingsForm.display_name}
435 onInput={linkEvent(this, this.handleDisplayNameChange)}
436 pattern="^(?!@)(.+)$"
441 <div class="form-group row">
442 <label class="col-sm-3 col-form-label" htmlFor="user-bio">
445 <div class="col-sm-9">
447 initialContent={this.state.saveUserSettingsForm.bio}
448 onContentChange={this.handleBioChange}
450 hideNavigationWarnings
454 <div class="form-group row">
455 <label class="col-sm-3 col-form-label" htmlFor="user-email">
458 <div class="col-sm-9">
463 placeholder={i18n.t("optional")}
464 value={this.state.saveUserSettingsForm.email}
465 onInput={linkEvent(this, this.handleEmailChange)}
470 <div class="form-group row">
471 <label class="col-sm-5 col-form-label" htmlFor="matrix-user-id">
472 <a href={elementUrl} rel={relTags}>
473 {i18n.t("matrix_user_id")}
476 <div class="col-sm-7">
481 placeholder="@user:example.com"
482 value={this.state.saveUserSettingsForm.matrix_user_id}
483 onInput={linkEvent(this, this.handleMatrixUserIdChange)}
484 pattern="^@[A-Za-z0-9._=-]+:[A-Za-z0-9.-]+\.[A-Za-z]{2,}$"
488 <div class="form-group row">
489 <label class="col-sm-3">{i18n.t("avatar")}</label>
490 <div class="col-sm-9">
492 uploadTitle={i18n.t("upload_avatar")}
493 imageSrc={this.state.saveUserSettingsForm.avatar}
494 onUpload={this.handleAvatarUpload}
495 onRemove={this.handleAvatarRemove}
500 <div class="form-group row">
501 <label class="col-sm-3">{i18n.t("banner")}</label>
502 <div class="col-sm-9">
504 uploadTitle={i18n.t("upload_banner")}
505 imageSrc={this.state.saveUserSettingsForm.banner}
506 onUpload={this.handleBannerUpload}
507 onRemove={this.handleBannerRemove}
511 <div class="form-group row">
512 <label class="col-sm-3" htmlFor="user-language">
515 <div class="col-sm-9">
518 value={this.state.saveUserSettingsForm.lang}
519 onChange={linkEvent(this, this.handleLangChange)}
520 class="custom-select w-auto"
522 <option disabled aria-hidden="true">
525 <option value="browser">{i18n.t("browser_default")}</option>
526 <option disabled aria-hidden="true">
530 .sort((a, b) => a.code.localeCompare(b.code))
532 <option value={lang.code}>{lang.name}</option>
537 <div class="form-group row">
538 <label class="col-sm-3" htmlFor="user-theme">
541 <div class="col-sm-9">
544 value={this.state.saveUserSettingsForm.theme}
545 onChange={linkEvent(this, this.handleThemeChange)}
546 class="custom-select w-auto"
548 <option disabled aria-hidden="true">
551 <option value="browser">{i18n.t("browser_default")}</option>
552 {this.state.themeList.map(theme => (
553 <option value={theme}>{theme}</option>
558 <form className="form-group row">
559 <label class="col-sm-3">{i18n.t("type")}</label>
560 <div class="col-sm-9">
563 Object.values(ListingType)[
564 this.state.saveUserSettingsForm.default_listing_type
567 showLocal={showLocal(this.isoData)}
569 onChange={this.handleListingTypeChange}
573 <form className="form-group row">
574 <label class="col-sm-3">{i18n.t("sort_type")}</label>
575 <div class="col-sm-9">
578 Object.values(SortType)[
579 this.state.saveUserSettingsForm.default_sort_type
582 onChange={this.handleSortTypeChange}
586 {this.state.siteRes.site_view.site.enable_nsfw && (
587 <div class="form-group">
588 <div class="form-check">
590 class="form-check-input"
593 checked={this.state.saveUserSettingsForm.show_nsfw}
594 onChange={linkEvent(this, this.handleShowNsfwChange)}
596 <label class="form-check-label" htmlFor="user-show-nsfw">
597 {i18n.t("show_nsfw")}
602 <div class="form-group">
603 <div class="form-check">
605 class="form-check-input"
606 id="user-show-scores"
608 checked={this.state.saveUserSettingsForm.show_scores}
609 onChange={linkEvent(this, this.handleShowScoresChange)}
611 <label class="form-check-label" htmlFor="user-show-scores">
612 {i18n.t("show_scores")}
616 <div class="form-group">
617 <div class="form-check">
619 class="form-check-input"
620 id="user-show-avatars"
622 checked={this.state.saveUserSettingsForm.show_avatars}
623 onChange={linkEvent(this, this.handleShowAvatarsChange)}
625 <label class="form-check-label" htmlFor="user-show-avatars">
626 {i18n.t("show_avatars")}
630 <div class="form-group">
631 <div class="form-check">
633 class="form-check-input"
634 id="user-bot-account"
636 checked={this.state.saveUserSettingsForm.bot_account}
637 onChange={linkEvent(this, this.handleBotAccount)}
639 <label class="form-check-label" htmlFor="user-bot-account">
640 {i18n.t("bot_account")}
644 <div class="form-group">
645 <div class="form-check">
647 class="form-check-input"
648 id="user-show-bot-accounts"
650 checked={this.state.saveUserSettingsForm.show_bot_accounts}
651 onChange={linkEvent(this, this.handleShowBotAccounts)}
653 <label class="form-check-label" htmlFor="user-show-bot-accounts">
654 {i18n.t("show_bot_accounts")}
658 <div class="form-group">
659 <div class="form-check">
661 class="form-check-input"
662 id="user-show-read-posts"
664 checked={this.state.saveUserSettingsForm.show_read_posts}
665 onChange={linkEvent(this, this.handleReadPosts)}
667 <label class="form-check-label" htmlFor="user-show-read-posts">
668 {i18n.t("show_read_posts")}
672 <div class="form-group">
673 <div class="form-check">
675 class="form-check-input"
676 id="user-show-new-post-notifs"
678 checked={this.state.saveUserSettingsForm.show_new_post_notifs}
679 onChange={linkEvent(this, this.handleShowNewPostNotifs)}
682 class="form-check-label"
683 htmlFor="user-show-new-post-notifs"
685 {i18n.t("show_new_post_notifs")}
689 <div class="form-group">
690 <div class="form-check">
692 class="form-check-input"
693 id="user-send-notifications-to-email"
695 disabled={!this.state.saveUserSettingsForm.email}
697 this.state.saveUserSettingsForm.send_notifications_to_email
701 this.handleSendNotificationsToEmailChange
705 class="form-check-label"
706 htmlFor="user-send-notifications-to-email"
708 {i18n.t("send_notifications_to_email")}
712 <div class="form-group">
713 <button type="submit" class="btn btn-block btn-secondary mr-4">
714 {this.state.saveUserSettingsLoading ? (
717 capitalizeFirstLetter(i18n.t("save"))
722 <div class="form-group">
724 class="btn btn-block btn-danger"
727 this.handleDeleteAccountShowConfirmToggle
730 {i18n.t("delete_account")}
732 {this.state.deleteAccountShowConfirm && (
734 <div class="my-2 alert alert-danger" role="alert">
735 {i18n.t("delete_account_confirm")}
739 value={this.state.deleteAccountForm.password}
740 autoComplete="new-password"
744 this.handleDeleteAccountPasswordChange
746 class="form-control my-2"
749 class="btn btn-danger mr-4"
750 disabled={!this.state.deleteAccountForm.password}
751 onClick={linkEvent(this, this.handleDeleteAccount)}
753 {this.state.deleteAccountLoading ? (
756 capitalizeFirstLetter(i18n.t("delete"))
760 class="btn btn-secondary"
763 this.handleDeleteAccountShowConfirmToggle
776 setupBlockPersonChoices() {
778 let selectId: any = document.getElementById("block-person-filter");
780 this.blockPersonChoices = new Choices(selectId, choicesConfig);
781 this.blockPersonChoices.passedElement.element.addEventListener(
784 this.handleBlockPerson(Number(e.detail.choice.value));
788 this.blockPersonChoices.passedElement.element.addEventListener(
790 debounce(async (e: any) => {
792 let persons = (await fetchUsers(e.detail.value)).users;
793 let choices = persons.map(pvs => personToChoice(pvs));
794 this.blockPersonChoices.setChoices(
810 setupBlockCommunityChoices() {
812 let selectId: any = document.getElementById("block-community-filter");
814 this.blockCommunityChoices = new Choices(selectId, choicesConfig);
815 this.blockCommunityChoices.passedElement.element.addEventListener(
818 this.handleBlockCommunity(Number(e.detail.choice.value));
822 this.blockCommunityChoices.passedElement.element.addEventListener(
824 debounce(async (e: any) => {
826 let communities = (await fetchCommunities(e.detail.value))
828 let choices = communities.map(cv => communityToChoice(cv));
829 this.blockCommunityChoices.setChoices(
845 handleBlockPerson(personId: number) {
847 let blockUserForm: BlockPerson = {
852 WebSocketService.Instance.send(wsClient.blockPerson(blockUserForm));
856 handleUnblockPerson(i: { ctx: Settings; recipientId: number }) {
857 let blockUserForm: BlockPerson = {
858 person_id: i.recipientId,
862 WebSocketService.Instance.send(wsClient.blockPerson(blockUserForm));
865 handleBlockCommunity(community_id: number) {
866 if (community_id != 0) {
867 let blockCommunityForm: BlockCommunity = {
872 WebSocketService.Instance.send(
873 wsClient.blockCommunity(blockCommunityForm)
878 handleUnblockCommunity(i: { ctx: Settings; communityId: number }) {
879 let blockCommunityForm: BlockCommunity = {
880 community_id: i.communityId,
884 WebSocketService.Instance.send(wsClient.blockCommunity(blockCommunityForm));
887 handleShowNsfwChange(i: Settings, event: any) {
888 i.state.saveUserSettingsForm.show_nsfw = event.target.checked;
892 handleShowAvatarsChange(i: Settings, event: any) {
893 i.state.saveUserSettingsForm.show_avatars = event.target.checked;
894 UserService.Instance.myUserInfo.local_user_view.local_user.show_avatars =
895 event.target.checked; // Just for instant updates
899 handleBotAccount(i: Settings, event: any) {
900 i.state.saveUserSettingsForm.bot_account = event.target.checked;
904 handleShowBotAccounts(i: Settings, event: any) {
905 i.state.saveUserSettingsForm.show_bot_accounts = event.target.checked;
909 handleReadPosts(i: Settings, event: any) {
910 i.state.saveUserSettingsForm.show_read_posts = event.target.checked;
914 handleShowNewPostNotifs(i: Settings, event: any) {
915 i.state.saveUserSettingsForm.show_new_post_notifs = event.target.checked;
919 handleShowScoresChange(i: Settings, event: any) {
920 i.state.saveUserSettingsForm.show_scores = event.target.checked;
921 UserService.Instance.myUserInfo.local_user_view.local_user.show_scores =
922 event.target.checked; // Just for instant updates
926 handleSendNotificationsToEmailChange(i: Settings, event: any) {
927 i.state.saveUserSettingsForm.send_notifications_to_email =
928 event.target.checked;
932 handleThemeChange(i: Settings, event: any) {
933 i.state.saveUserSettingsForm.theme = event.target.value;
934 setTheme(event.target.value, true);
938 handleLangChange(i: Settings, event: any) {
939 i.state.saveUserSettingsForm.lang = event.target.value;
940 i18n.changeLanguage(getLanguages(i.state.saveUserSettingsForm.lang)[0]);
944 handleSortTypeChange(val: SortType) {
945 this.state.saveUserSettingsForm.default_sort_type =
946 Object.keys(SortType).indexOf(val);
947 this.setState(this.state);
950 handleListingTypeChange(val: ListingType) {
951 this.state.saveUserSettingsForm.default_listing_type =
952 Object.keys(ListingType).indexOf(val);
953 this.setState(this.state);
956 handleEmailChange(i: Settings, event: any) {
957 i.state.saveUserSettingsForm.email = event.target.value;
961 handleBioChange(val: string) {
962 this.state.saveUserSettingsForm.bio = val;
963 this.setState(this.state);
966 handleAvatarUpload(url: string) {
967 this.state.saveUserSettingsForm.avatar = url;
968 this.setState(this.state);
971 handleAvatarRemove() {
972 this.state.saveUserSettingsForm.avatar = "";
973 this.setState(this.state);
976 handleBannerUpload(url: string) {
977 this.state.saveUserSettingsForm.banner = url;
978 this.setState(this.state);
981 handleBannerRemove() {
982 this.state.saveUserSettingsForm.banner = "";
983 this.setState(this.state);
986 handleDisplayNameChange(i: Settings, event: any) {
987 i.state.saveUserSettingsForm.display_name = event.target.value;
991 handleMatrixUserIdChange(i: Settings, event: any) {
992 i.state.saveUserSettingsForm.matrix_user_id = event.target.value;
994 i.state.saveUserSettingsForm.matrix_user_id == "" &&
995 !UserService.Instance.myUserInfo.local_user_view.person.matrix_user_id
997 i.state.saveUserSettingsForm.matrix_user_id = undefined;
1002 handleNewPasswordChange(i: Settings, event: any) {
1003 i.state.changePasswordForm.new_password = event.target.value;
1004 if (i.state.changePasswordForm.new_password == "") {
1005 i.state.changePasswordForm.new_password = undefined;
1007 i.setState(i.state);
1010 handleNewPasswordVerifyChange(i: Settings, event: any) {
1011 i.state.changePasswordForm.new_password_verify = event.target.value;
1012 if (i.state.changePasswordForm.new_password_verify == "") {
1013 i.state.changePasswordForm.new_password_verify = undefined;
1015 i.setState(i.state);
1018 handleOldPasswordChange(i: Settings, event: any) {
1019 i.state.changePasswordForm.old_password = event.target.value;
1020 if (i.state.changePasswordForm.old_password == "") {
1021 i.state.changePasswordForm.old_password = undefined;
1023 i.setState(i.state);
1026 handleSaveSettingsSubmit(i: Settings, event: any) {
1027 event.preventDefault();
1028 i.state.saveUserSettingsLoading = true;
1029 i.setState(i.state);
1031 WebSocketService.Instance.send(
1032 wsClient.saveUserSettings(i.state.saveUserSettingsForm)
1036 handleChangePasswordSubmit(i: Settings, event: any) {
1037 event.preventDefault();
1038 i.state.changePasswordLoading = true;
1039 i.setState(i.state);
1041 WebSocketService.Instance.send(
1042 wsClient.changePassword(i.state.changePasswordForm)
1046 handleDeleteAccountShowConfirmToggle(i: Settings, event: any) {
1047 event.preventDefault();
1048 i.state.deleteAccountShowConfirm = !i.state.deleteAccountShowConfirm;
1049 i.setState(i.state);
1052 handleDeleteAccountPasswordChange(i: Settings, event: any) {
1053 i.state.deleteAccountForm.password = event.target.value;
1054 i.setState(i.state);
1057 handleDeleteAccount(i: Settings, event: any) {
1058 event.preventDefault();
1059 i.state.deleteAccountLoading = true;
1060 i.setState(i.state);
1062 WebSocketService.Instance.send(
1063 wsClient.deleteAccount(i.state.deleteAccountForm)
1067 handleSwitchTab(i: { ctx: Settings; tab: string }) {
1068 i.ctx.setState({ currentTab: i.tab });
1070 if (i.ctx.state.currentTab == "blocks") {
1071 i.ctx.setupBlockPersonChoices();
1072 i.ctx.setupBlockCommunityChoices();
1077 let luv = UserService.Instance.myUserInfo.local_user_view;
1078 this.state.saveUserSettingsForm.show_nsfw = luv.local_user.show_nsfw;
1079 this.state.saveUserSettingsForm.theme = luv.local_user.theme
1080 ? luv.local_user.theme
1082 this.state.saveUserSettingsForm.default_sort_type =
1083 luv.local_user.default_sort_type;
1084 this.state.saveUserSettingsForm.default_listing_type =
1085 luv.local_user.default_listing_type;
1086 this.state.saveUserSettingsForm.lang = luv.local_user.lang;
1087 this.state.saveUserSettingsForm.avatar = luv.person.avatar;
1088 this.state.saveUserSettingsForm.banner = luv.person.banner;
1089 this.state.saveUserSettingsForm.display_name = luv.person.display_name;
1090 this.state.saveUserSettingsForm.show_avatars = luv.local_user.show_avatars;
1091 this.state.saveUserSettingsForm.bot_account = luv.person.bot_account;
1092 this.state.saveUserSettingsForm.show_bot_accounts =
1093 luv.local_user.show_bot_accounts;
1094 this.state.saveUserSettingsForm.show_scores = luv.local_user.show_scores;
1095 this.state.saveUserSettingsForm.show_read_posts =
1096 luv.local_user.show_read_posts;
1097 this.state.saveUserSettingsForm.show_new_post_notifs =
1098 luv.local_user.show_new_post_notifs;
1099 this.state.saveUserSettingsForm.email = luv.local_user.email;
1100 this.state.saveUserSettingsForm.bio = luv.person.bio;
1101 this.state.saveUserSettingsForm.send_notifications_to_email =
1102 luv.local_user.send_notifications_to_email;
1103 this.state.saveUserSettingsForm.matrix_user_id = luv.person.matrix_user_id;
1104 this.state.personBlocks = UserService.Instance.myUserInfo.person_blocks;
1105 this.state.communityBlocks =
1106 UserService.Instance.myUserInfo.community_blocks;
1109 parseMessage(msg: any) {
1110 let op = wsUserOp(msg);
1114 saveUserSettingsLoading: false,
1115 changePasswordLoading: false,
1116 deleteAccountLoading: false,
1118 toast(i18n.t(msg.error), "danger");
1120 } else if (op == UserOperation.SaveUserSettings) {
1121 let data = wsJsonToRes<LoginResponse>(msg).data;
1122 UserService.Instance.login(data);
1123 this.state.saveUserSettingsLoading = false;
1124 this.setState(this.state);
1126 window.scrollTo(0, 0);
1127 } else if (op == UserOperation.ChangePassword) {
1128 let data = wsJsonToRes<LoginResponse>(msg).data;
1129 UserService.Instance.login(data);
1130 this.state.changePasswordLoading = false;
1131 this.setState(this.state);
1132 window.scrollTo(0, 0);
1133 toast(i18n.t("password_changed"));
1134 } else if (op == UserOperation.DeleteAccount) {
1136 deleteAccountLoading: false,
1137 deleteAccountShowConfirm: false,
1139 UserService.Instance.logout();
1140 window.location.href = "/";
1142 } else if (op == UserOperation.BlockPerson) {
1143 let data = wsJsonToRes<BlockPersonResponse>(msg).data;
1144 this.setState({ personBlocks: updatePersonBlock(data) });
1145 } else if (op == UserOperation.BlockCommunity) {
1146 let data = wsJsonToRes<BlockCommunityResponse>(msg).data;
1147 this.setState({ communityBlocks: updateCommunityBlock(data) });