X-Git-Url: http://these/git/?a=blobdiff_plain;f=src%2Fshared%2Fcomponents%2Fperson%2Fsettings.tsx;h=4caef458bbe84600baa0906672b36867bb92ca09;hb=c3ab9e74f8775f4b811866d2675b00f9702bde3d;hp=5c3fc345c9433c556a07a9ddd50a80aba47b02f6;hpb=ced7b887d21bc53b5b3ac18c535a70f74d705f04;p=lemmy-ui.git
diff --git a/src/shared/components/person/settings.tsx b/src/shared/components/person/settings.tsx
index 5c3fc34..4caef45 100644
--- a/src/shared/components/person/settings.tsx
+++ b/src/shared/components/person/settings.tsx
@@ -1,4 +1,20 @@
-import { debounce } from "@utils/helpers";
+import {
+ communityToChoice,
+ fetchCommunities,
+ fetchThemeList,
+ fetchUsers,
+ myAuth,
+ myAuthRequired,
+ personToChoice,
+ setIsoData,
+ setTheme,
+ showLocal,
+ updateCommunityBlock,
+ updatePersonBlock,
+} from "@utils/app";
+import { capitalizeFirstLetter, debounce } from "@utils/helpers";
+import { Choice } from "@utils/types";
+import classNames from "classnames";
import { NoOptionI18nKeys } from "i18next";
import { Component, linkEvent } from "inferno";
import {
@@ -12,30 +28,12 @@ import {
PersonBlockView,
SortType,
} from "lemmy-js-client";
-import { i18n, languages } from "../../i18next";
+import { elementUrl, emDash, relTags } from "../../config";
import { UserService } from "../../services";
import { HttpService, RequestState } from "../../services/HttpService";
-import {
- Choice,
- capitalizeFirstLetter,
- communityToChoice,
- elementUrl,
- emDash,
- fetchCommunities,
- fetchThemeList,
- fetchUsers,
- myAuth,
- myAuthRequired,
- personToChoice,
- relTags,
- setIsoData,
- setTheme,
- setupTippy,
- showLocal,
- toast,
- updateCommunityBlock,
- updatePersonBlock,
-} from "../../utils";
+import { I18NextService, languages } from "../../services/I18NextService";
+import { setupTippy } from "../../tippy";
+import { toast } from "../../toast";
import { HtmlTags } from "../common/html-tags";
import { Icon, Spinner } from "../common/icon";
import { ImageUploadForm } from "../common/image-upload-form";
@@ -115,7 +113,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() {
@@ -251,12 +249,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,
},
]}
@@ -265,34 +263,50 @@ export class Settings extends Component {
);
}
- userSettings() {
+ userSettings(isSelected) {
return (
-
-
-
-
{this.saveUserSettingsHtmlForm()}
+
+
+
+
+
{this.saveUserSettingsHtmlForm()}
+
-
-
-
-
{this.changePasswordHtmlForm()}
+
+
+
{this.changePasswordHtmlForm()}
+
);
}
- blockCards() {
+ blockCards(isSelected) {
return (
-
-
-
-
{this.blockUserCard()}
+
+
+
+
+
{this.blockUserCard()}
+
-
-
-
-
{this.blockCommunityCard()}
+
+
+
{this.blockCommunityCard()}
+
@@ -302,11 +316,11 @@ export class Settings extends Component
{
changePasswordHtmlForm() {
return (
<>
- {i18n.t("change_password")}
+ {I18NextService.i18n.t("change_password")}
@@ -786,7 +808,7 @@ export class Settings extends Component
{
{this.state.saveRes.state === "loading" ? (
) : (
- capitalizeFirstLetter(i18n.t("save"))
+ capitalizeFirstLetter(I18NextService.i18n.t("save"))
)}
@@ -799,12 +821,12 @@ export class Settings extends Component
{
this.handleDeleteAccountShowConfirmToggle
)}
>
- {i18n.t("delete_account")}
+ {I18NextService.i18n.t("delete_account")}
{this.state.deleteAccountShowConfirm && (
<>
- {i18n.t("delete_account_confirm")}
+ {I18NextService.i18n.t("delete_account_confirm")}
{
{this.state.deleteAccountRes.state === "loading" ? (
) : (
- capitalizeFirstLetter(i18n.t("delete"))
+ capitalizeFirstLetter(I18NextService.i18n.t("delete"))
)}
>
)}
@@ -862,7 +884,7 @@ export class Settings extends Component {
onChange={linkEvent(this, this.handleGenerateTotp)}
/>
@@ -872,7 +894,7 @@ export class Settings extends Component
{
<>
@@ -887,7 +909,7 @@ export class Settings extends Component
{
onChange={linkEvent(this, this.handleRemoveTotp)}
/>
@@ -1036,7 +1058,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));
}
@@ -1064,7 +1086,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)
@@ -1151,10 +1175,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);
}
@@ -1175,9 +1202,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 });