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)}
568 onChange={this.handleListingTypeChange}
572 <form className="form-group row">
573 <label class="col-sm-3">{i18n.t("sort_type")}</label>
574 <div class="col-sm-9">
577 Object.values(SortType)[
578 this.state.saveUserSettingsForm.default_sort_type
581 onChange={this.handleSortTypeChange}
585 {this.state.siteRes.site_view.site.enable_nsfw && (
586 <div class="form-group">
587 <div class="form-check">
589 class="form-check-input"
592 checked={this.state.saveUserSettingsForm.show_nsfw}
593 onChange={linkEvent(this, this.handleShowNsfwChange)}
595 <label class="form-check-label" htmlFor="user-show-nsfw">
596 {i18n.t("show_nsfw")}
601 <div class="form-group">
602 <div class="form-check">
604 class="form-check-input"
605 id="user-show-scores"
607 checked={this.state.saveUserSettingsForm.show_scores}
608 onChange={linkEvent(this, this.handleShowScoresChange)}
610 <label class="form-check-label" htmlFor="user-show-scores">
611 {i18n.t("show_scores")}
615 <div class="form-group">
616 <div class="form-check">
618 class="form-check-input"
619 id="user-show-avatars"
621 checked={this.state.saveUserSettingsForm.show_avatars}
622 onChange={linkEvent(this, this.handleShowAvatarsChange)}
624 <label class="form-check-label" htmlFor="user-show-avatars">
625 {i18n.t("show_avatars")}
629 <div class="form-group">
630 <div class="form-check">
632 class="form-check-input"
633 id="user-bot-account"
635 checked={this.state.saveUserSettingsForm.bot_account}
636 onChange={linkEvent(this, this.handleBotAccount)}
638 <label class="form-check-label" htmlFor="user-bot-account">
639 {i18n.t("bot_account")}
643 <div class="form-group">
644 <div class="form-check">
646 class="form-check-input"
647 id="user-show-bot-accounts"
649 checked={this.state.saveUserSettingsForm.show_bot_accounts}
650 onChange={linkEvent(this, this.handleShowBotAccounts)}
652 <label class="form-check-label" htmlFor="user-show-bot-accounts">
653 {i18n.t("show_bot_accounts")}
657 <div class="form-group">
658 <div class="form-check">
660 class="form-check-input"
661 id="user-show-read-posts"
663 checked={this.state.saveUserSettingsForm.show_read_posts}
664 onChange={linkEvent(this, this.handleReadPosts)}
666 <label class="form-check-label" htmlFor="user-show-read-posts">
667 {i18n.t("show_read_posts")}
671 <div class="form-group">
672 <div class="form-check">
674 class="form-check-input"
675 id="user-show-new-post-notifs"
677 checked={this.state.saveUserSettingsForm.show_new_post_notifs}
678 onChange={linkEvent(this, this.handleShowNewPostNotifs)}
681 class="form-check-label"
682 htmlFor="user-show-new-post-notifs"
684 {i18n.t("show_new_post_notifs")}
688 <div class="form-group">
689 <div class="form-check">
691 class="form-check-input"
692 id="user-send-notifications-to-email"
694 disabled={!this.state.saveUserSettingsForm.email}
696 this.state.saveUserSettingsForm.send_notifications_to_email
700 this.handleSendNotificationsToEmailChange
704 class="form-check-label"
705 htmlFor="user-send-notifications-to-email"
707 {i18n.t("send_notifications_to_email")}
711 <div class="form-group">
712 <button type="submit" class="btn btn-block btn-secondary mr-4">
713 {this.state.saveUserSettingsLoading ? (
716 capitalizeFirstLetter(i18n.t("save"))
721 <div class="form-group">
723 class="btn btn-block btn-danger"
726 this.handleDeleteAccountShowConfirmToggle
729 {i18n.t("delete_account")}
731 {this.state.deleteAccountShowConfirm && (
733 <div class="my-2 alert alert-danger" role="alert">
734 {i18n.t("delete_account_confirm")}
738 value={this.state.deleteAccountForm.password}
739 autoComplete="new-password"
743 this.handleDeleteAccountPasswordChange
745 class="form-control my-2"
748 class="btn btn-danger mr-4"
749 disabled={!this.state.deleteAccountForm.password}
750 onClick={linkEvent(this, this.handleDeleteAccount)}
752 {this.state.deleteAccountLoading ? (
755 capitalizeFirstLetter(i18n.t("delete"))
759 class="btn btn-secondary"
762 this.handleDeleteAccountShowConfirmToggle
775 setupBlockPersonChoices() {
777 let selectId: any = document.getElementById("block-person-filter");
779 this.blockPersonChoices = new Choices(selectId, choicesConfig);
780 this.blockPersonChoices.passedElement.element.addEventListener(
783 this.handleBlockPerson(Number(e.detail.choice.value));
787 this.blockPersonChoices.passedElement.element.addEventListener(
789 debounce(async (e: any) => {
791 let persons = (await fetchUsers(e.detail.value)).users;
792 let choices = persons.map(pvs => personToChoice(pvs));
793 this.blockPersonChoices.setChoices(
809 setupBlockCommunityChoices() {
811 let selectId: any = document.getElementById("block-community-filter");
813 this.blockCommunityChoices = new Choices(selectId, choicesConfig);
814 this.blockCommunityChoices.passedElement.element.addEventListener(
817 this.handleBlockCommunity(Number(e.detail.choice.value));
821 this.blockCommunityChoices.passedElement.element.addEventListener(
823 debounce(async (e: any) => {
825 let communities = (await fetchCommunities(e.detail.value))
827 let choices = communities.map(cv => communityToChoice(cv));
828 this.blockCommunityChoices.setChoices(
844 handleBlockPerson(personId: number) {
846 let blockUserForm: BlockPerson = {
851 WebSocketService.Instance.send(wsClient.blockPerson(blockUserForm));
855 handleUnblockPerson(i: { ctx: Settings; recipientId: number }) {
856 let blockUserForm: BlockPerson = {
857 person_id: i.recipientId,
861 WebSocketService.Instance.send(wsClient.blockPerson(blockUserForm));
864 handleBlockCommunity(community_id: number) {
865 if (community_id != 0) {
866 let blockCommunityForm: BlockCommunity = {
871 WebSocketService.Instance.send(
872 wsClient.blockCommunity(blockCommunityForm)
877 handleUnblockCommunity(i: { ctx: Settings; communityId: number }) {
878 let blockCommunityForm: BlockCommunity = {
879 community_id: i.communityId,
883 WebSocketService.Instance.send(wsClient.blockCommunity(blockCommunityForm));
886 handleShowNsfwChange(i: Settings, event: any) {
887 i.state.saveUserSettingsForm.show_nsfw = event.target.checked;
891 handleShowAvatarsChange(i: Settings, event: any) {
892 i.state.saveUserSettingsForm.show_avatars = event.target.checked;
893 UserService.Instance.myUserInfo.local_user_view.local_user.show_avatars =
894 event.target.checked; // Just for instant updates
898 handleBotAccount(i: Settings, event: any) {
899 i.state.saveUserSettingsForm.bot_account = event.target.checked;
903 handleShowBotAccounts(i: Settings, event: any) {
904 i.state.saveUserSettingsForm.show_bot_accounts = event.target.checked;
908 handleReadPosts(i: Settings, event: any) {
909 i.state.saveUserSettingsForm.show_read_posts = event.target.checked;
913 handleShowNewPostNotifs(i: Settings, event: any) {
914 i.state.saveUserSettingsForm.show_new_post_notifs = event.target.checked;
918 handleShowScoresChange(i: Settings, event: any) {
919 i.state.saveUserSettingsForm.show_scores = event.target.checked;
920 UserService.Instance.myUserInfo.local_user_view.local_user.show_scores =
921 event.target.checked; // Just for instant updates
925 handleSendNotificationsToEmailChange(i: Settings, event: any) {
926 i.state.saveUserSettingsForm.send_notifications_to_email =
927 event.target.checked;
931 handleThemeChange(i: Settings, event: any) {
932 i.state.saveUserSettingsForm.theme = event.target.value;
933 setTheme(event.target.value, true);
937 handleLangChange(i: Settings, event: any) {
938 i.state.saveUserSettingsForm.lang = event.target.value;
939 i18n.changeLanguage(getLanguages(i.state.saveUserSettingsForm.lang)[0]);
943 handleSortTypeChange(val: SortType) {
944 this.state.saveUserSettingsForm.default_sort_type =
945 Object.keys(SortType).indexOf(val);
946 this.setState(this.state);
949 handleListingTypeChange(val: ListingType) {
950 this.state.saveUserSettingsForm.default_listing_type =
951 Object.keys(ListingType).indexOf(val);
952 this.setState(this.state);
955 handleEmailChange(i: Settings, event: any) {
956 i.state.saveUserSettingsForm.email = event.target.value;
960 handleBioChange(val: string) {
961 this.state.saveUserSettingsForm.bio = val;
962 this.setState(this.state);
965 handleAvatarUpload(url: string) {
966 this.state.saveUserSettingsForm.avatar = url;
967 this.setState(this.state);
970 handleAvatarRemove() {
971 this.state.saveUserSettingsForm.avatar = "";
972 this.setState(this.state);
975 handleBannerUpload(url: string) {
976 this.state.saveUserSettingsForm.banner = url;
977 this.setState(this.state);
980 handleBannerRemove() {
981 this.state.saveUserSettingsForm.banner = "";
982 this.setState(this.state);
985 handleDisplayNameChange(i: Settings, event: any) {
986 i.state.saveUserSettingsForm.display_name = event.target.value;
990 handleMatrixUserIdChange(i: Settings, event: any) {
991 i.state.saveUserSettingsForm.matrix_user_id = event.target.value;
993 i.state.saveUserSettingsForm.matrix_user_id == "" &&
994 !UserService.Instance.myUserInfo.local_user_view.person.matrix_user_id
996 i.state.saveUserSettingsForm.matrix_user_id = undefined;
1001 handleNewPasswordChange(i: Settings, event: any) {
1002 i.state.changePasswordForm.new_password = event.target.value;
1003 if (i.state.changePasswordForm.new_password == "") {
1004 i.state.changePasswordForm.new_password = undefined;
1006 i.setState(i.state);
1009 handleNewPasswordVerifyChange(i: Settings, event: any) {
1010 i.state.changePasswordForm.new_password_verify = event.target.value;
1011 if (i.state.changePasswordForm.new_password_verify == "") {
1012 i.state.changePasswordForm.new_password_verify = undefined;
1014 i.setState(i.state);
1017 handleOldPasswordChange(i: Settings, event: any) {
1018 i.state.changePasswordForm.old_password = event.target.value;
1019 if (i.state.changePasswordForm.old_password == "") {
1020 i.state.changePasswordForm.old_password = undefined;
1022 i.setState(i.state);
1025 handleSaveSettingsSubmit(i: Settings, event: any) {
1026 event.preventDefault();
1027 i.state.saveUserSettingsLoading = true;
1028 i.setState(i.state);
1030 WebSocketService.Instance.send(
1031 wsClient.saveUserSettings(i.state.saveUserSettingsForm)
1035 handleChangePasswordSubmit(i: Settings, event: any) {
1036 event.preventDefault();
1037 i.state.changePasswordLoading = true;
1038 i.setState(i.state);
1040 WebSocketService.Instance.send(
1041 wsClient.changePassword(i.state.changePasswordForm)
1045 handleDeleteAccountShowConfirmToggle(i: Settings, event: any) {
1046 event.preventDefault();
1047 i.state.deleteAccountShowConfirm = !i.state.deleteAccountShowConfirm;
1048 i.setState(i.state);
1051 handleDeleteAccountPasswordChange(i: Settings, event: any) {
1052 i.state.deleteAccountForm.password = event.target.value;
1053 i.setState(i.state);
1056 handleDeleteAccount(i: Settings, event: any) {
1057 event.preventDefault();
1058 i.state.deleteAccountLoading = true;
1059 i.setState(i.state);
1061 WebSocketService.Instance.send(
1062 wsClient.deleteAccount(i.state.deleteAccountForm)
1066 handleSwitchTab(i: { ctx: Settings; tab: string }) {
1067 i.ctx.setState({ currentTab: i.tab });
1069 if (i.ctx.state.currentTab == "blocks") {
1070 i.ctx.setupBlockPersonChoices();
1071 i.ctx.setupBlockCommunityChoices();
1076 let luv = UserService.Instance.myUserInfo.local_user_view;
1077 this.state.saveUserSettingsForm.show_nsfw = luv.local_user.show_nsfw;
1078 this.state.saveUserSettingsForm.theme = luv.local_user.theme
1079 ? luv.local_user.theme
1081 this.state.saveUserSettingsForm.default_sort_type =
1082 luv.local_user.default_sort_type;
1083 this.state.saveUserSettingsForm.default_listing_type =
1084 luv.local_user.default_listing_type;
1085 this.state.saveUserSettingsForm.lang = luv.local_user.lang;
1086 this.state.saveUserSettingsForm.avatar = luv.person.avatar;
1087 this.state.saveUserSettingsForm.banner = luv.person.banner;
1088 this.state.saveUserSettingsForm.display_name = luv.person.display_name;
1089 this.state.saveUserSettingsForm.show_avatars = luv.local_user.show_avatars;
1090 this.state.saveUserSettingsForm.bot_account = luv.person.bot_account;
1091 this.state.saveUserSettingsForm.show_bot_accounts =
1092 luv.local_user.show_bot_accounts;
1093 this.state.saveUserSettingsForm.show_scores = luv.local_user.show_scores;
1094 this.state.saveUserSettingsForm.show_read_posts =
1095 luv.local_user.show_read_posts;
1096 this.state.saveUserSettingsForm.show_new_post_notifs =
1097 luv.local_user.show_new_post_notifs;
1098 this.state.saveUserSettingsForm.email = luv.local_user.email;
1099 this.state.saveUserSettingsForm.bio = luv.person.bio;
1100 this.state.saveUserSettingsForm.send_notifications_to_email =
1101 luv.local_user.send_notifications_to_email;
1102 this.state.saveUserSettingsForm.matrix_user_id = luv.person.matrix_user_id;
1103 this.state.personBlocks = UserService.Instance.myUserInfo.person_blocks;
1104 this.state.communityBlocks =
1105 UserService.Instance.myUserInfo.community_blocks;
1108 parseMessage(msg: any) {
1109 let op = wsUserOp(msg);
1113 saveUserSettingsLoading: false,
1114 changePasswordLoading: false,
1115 deleteAccountLoading: false,
1117 toast(i18n.t(msg.error), "danger");
1119 } else if (op == UserOperation.SaveUserSettings) {
1120 let data = wsJsonToRes<LoginResponse>(msg).data;
1121 UserService.Instance.login(data);
1122 this.state.saveUserSettingsLoading = false;
1123 this.setState(this.state);
1125 window.scrollTo(0, 0);
1126 } else if (op == UserOperation.ChangePassword) {
1127 let data = wsJsonToRes<LoginResponse>(msg).data;
1128 UserService.Instance.login(data);
1129 this.state.changePasswordLoading = false;
1130 this.setState(this.state);
1131 window.scrollTo(0, 0);
1132 toast(i18n.t("password_changed"));
1133 } else if (op == UserOperation.DeleteAccount) {
1135 deleteAccountLoading: false,
1136 deleteAccountShowConfirm: false,
1138 UserService.Instance.logout();
1139 window.location.href = "/";
1141 } else if (op == UserOperation.BlockPerson) {
1142 let data = wsJsonToRes<BlockPersonResponse>(msg).data;
1143 this.setState({ personBlocks: updatePersonBlock(data) });
1144 } else if (op == UserOperation.BlockCommunity) {
1145 let data = wsJsonToRes<BlockCommunityResponse>(msg).data;
1146 this.setState({ communityBlocks: updateCommunityBlock(data) });