X-Git-Url: http://these/git/?a=blobdiff_plain;f=src%2Fshared%2Fcomponents%2Fperson%2Fsettings.tsx;h=d024aae222b80081fa9941401443cfdc25353173;hb=b7ec7ae3110c560968e0cb24a32f1fe9166eec29;hp=5f149dfe2960b569f17262c9874cd3a9819175db;hpb=0beb2a434195f2d6f20bb7521aa973f3a63ed8d3;p=lemmy-ui.git
diff --git a/src/shared/components/person/settings.tsx b/src/shared/components/person/settings.tsx
index 5f149df..d024aae 100644
--- a/src/shared/components/person/settings.tsx
+++ b/src/shared/components/person/settings.tsx
@@ -29,9 +29,9 @@ import {
SortType,
} from "lemmy-js-client";
import { elementUrl, emDash, relTags } from "../../config";
-import { i18n, languages } from "../../i18next";
import { UserService } from "../../services";
import { HttpService, RequestState } from "../../services/HttpService";
+import { I18NextService, languages } from "../../services/I18NextService";
import { setupTippy } from "../../tippy";
import { toast } from "../../toast";
import { HtmlTags } from "../common/html-tags";
@@ -40,6 +40,7 @@ import { ImageUploadForm } from "../common/image-upload-form";
import { LanguageSelect } from "../common/language-select";
import { ListingTypeSelect } from "../common/listing-type-select";
import { MarkdownTextArea } from "../common/markdown-textarea";
+import PasswordInput from "../common/password-input";
import { SearchableSelect } from "../common/searchable-select";
import { SortSelect } from "../common/sort-select";
import Tabs from "../common/tabs";
@@ -113,7 +114,7 @@ const Filter = ({
className="col-md-4 col-form-label"
htmlFor={`block-${filterType}-filter`}
>
- {i18n.t(`block_${filterType}` as NoOptionI18nKeys)}
+ {I18NextService.i18n.t(`block_${filterType}` as NoOptionI18nKeys)}
{
}
get documentTitle(): string {
- return i18n.t("settings");
+ return I18NextService.i18n.t("settings");
}
render() {
@@ -249,12 +250,12 @@ export class Settings extends Component {
tabs={[
{
key: "settings",
- label: i18n.t("settings"),
+ label: I18NextService.i18n.t("settings"),
getNode: this.userSettings,
},
{
key: "blocks",
- label: i18n.t("blocks"),
+ label: I18NextService.i18n.t("blocks"),
getNode: this.blockCards,
},
]}
@@ -316,61 +317,32 @@ export class Settings extends Component {
changePasswordHtmlForm() {
return (
<>
- {i18n.t("change_password")}
+ {I18NextService.i18n.t("change_password")}
@@ -800,60 +783,67 @@ export class Settings extends Component {
{this.state.saveRes.state === "loading" ? (
) : (
- capitalizeFirstLetter(i18n.t("save"))
+ capitalizeFirstLetter(I18NextService.i18n.t("save"))
)}
-
+
>
);
@@ -876,7 +866,7 @@ export class Settings extends Component {
onChange={linkEvent(this, this.handleGenerateTotp)}
/>
@@ -886,7 +876,7 @@ export class Settings extends Component {
<>
@@ -901,7 +891,7 @@ export class Settings extends Component
{
onChange={linkEvent(this, this.handleRemoveTotp)}
/>
@@ -1050,7 +1040,7 @@ export class Settings extends Component {
// Coerce false to undefined here, so it won't generate it.
const checked: boolean | undefined = event.target.checked || undefined;
if (checked) {
- toast(i18n.t("two_factor_setup_instructions"));
+ toast(I18NextService.i18n.t("two_factor_setup_instructions"));
}
i.setState(s => ((s.saveUserSettingsForm.generate_totp_2fa = checked), s));
}
@@ -1078,7 +1068,9 @@ export class Settings extends Component {
handleInterfaceLangChange(i: Settings, event: any) {
const newLang = event.target.value ?? "browser";
- i18n.changeLanguage(newLang === "browser" ? navigator.languages : newLang);
+ I18NextService.i18n.changeLanguage(
+ newLang === "browser" ? navigator.languages : newLang
+ );
i.setState(
s => ((s.saveUserSettingsForm.interface_language = event.target.value), s)
@@ -1165,10 +1157,13 @@ export class Settings extends Component {
...i.state.saveUserSettingsForm,
auth: myAuthRequired(),
});
+
if (saveRes.state === "success") {
- UserService.Instance.login(saveRes.data);
- location.reload();
- toast(i18n.t("saved"));
+ UserService.Instance.login({
+ res: saveRes.data,
+ showToast: false,
+ });
+ toast(I18NextService.i18n.t("saved"));
window.scrollTo(0, 0);
}
@@ -1189,9 +1184,12 @@ export class Settings extends Component {
auth: myAuthRequired(),
});
if (changePasswordRes.state === "success") {
- UserService.Instance.login(changePasswordRes.data);
+ UserService.Instance.login({
+ res: changePasswordRes.data,
+ showToast: false,
+ });
window.scrollTo(0, 0);
- toast(i18n.t("password_changed"));
+ toast(I18NextService.i18n.t("password_changed"));
}
i.setState({ changePasswordRes });
@@ -1206,7 +1204,8 @@ export class Settings extends Component {
i.setState(s => ((s.deleteAccountForm.password = event.target.value), s));
}
- async handleDeleteAccount(i: Settings) {
+ async handleDeleteAccount(i: Settings, event: Event) {
+ event.preventDefault();
const password = i.state.deleteAccountForm.password;
if (password) {
i.setState({ deleteAccountRes: { state: "loading" } });