X-Git-Url: http://these/git/?a=blobdiff_plain;f=src%2Fshared%2Fcomponents%2Fperson%2Fsettings.tsx;h=4caef458bbe84600baa0906672b36867bb92ca09;hb=c3ab9e74f8775f4b811866d2675b00f9702bde3d;hp=5f149dfe2960b569f17262c9874cd3a9819175db;hpb=51091185252f8796ed8adb6b77a032d8d1cc6961;p=lemmy-ui.git diff --git a/src/shared/components/person/settings.tsx b/src/shared/components/person/settings.tsx index 5f149df..4caef45 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"; @@ -113,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() { @@ -249,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, }, ]} @@ -316,11 +316,11 @@ export class Settings extends Component { changePasswordHtmlForm() { return ( <> -
{i18n.t("change_password")}
+

{I18NextService.i18n.t("change_password")}

{ className="col-sm-5 col-form-label" htmlFor="user-verify-password" > - {i18n.t("verify_password")} + {I18NextService.i18n.t("verify_password")}
{ className="col-sm-5 col-form-label" htmlFor="user-old-password" > - {i18n.t("old_password")} + {I18NextService.i18n.t("old_password")}
{ {this.state.changePasswordRes.state === "loading" ? ( ) : ( - capitalizeFirstLetter(i18n.t("save")) + capitalizeFirstLetter(I18NextService.i18n.t("save")) )}
@@ -409,7 +409,7 @@ export class Settings extends Component { blockedUsersList() { return ( <> -
{i18n.t("blocked_users")}
+

{I18NextService.i18n.t("blocked_users")}

    {this.state.personBlocks.map(pb => (
  • @@ -421,7 +421,7 @@ export class Settings extends Component { { ctx: this, recipientId: pb.target.id }, this.handleUnblockPerson )} - data-tippy-content={i18n.t("unblock_user")} + data-tippy-content={I18NextService.i18n.t("unblock_user")} > @@ -453,7 +453,7 @@ export class Settings extends Component { blockedCommunitiesList() { return ( <> -
    {i18n.t("blocked_communities")}
    +

    {I18NextService.i18n.t("blocked_communities")}

      {this.state.communityBlocks.map(cb => (
    • @@ -465,7 +465,9 @@ export class Settings extends Component { { ctx: this, communityId: cb.community.id }, this.handleUnblockCommunity )} - data-tippy-content={i18n.t("unblock_community")} + data-tippy-content={I18NextService.i18n.t( + "unblock_community" + )} > @@ -482,18 +484,18 @@ export class Settings extends Component { return ( <> -
      {i18n.t("settings")}
      +

      {I18NextService.i18n.t("settings")}

      {
      {
      {
      @@ -552,11 +554,11 @@ export class Settings extends Component {
      {
      {
      { className="form-select d-inline-block w-auto" > + - {this.state.themeList.map(theme => (
      - +
      {
      { onChange={linkEvent(this, this.handleShowNsfwChange)} />
      @@ -688,7 +696,7 @@ export class Settings extends Component { onChange={linkEvent(this, this.handleShowScoresChange)} />
      @@ -702,7 +710,7 @@ export class Settings extends Component { onChange={linkEvent(this, this.handleShowAvatarsChange)} />
      @@ -716,7 +724,7 @@ export class Settings extends Component { onChange={linkEvent(this, this.handleBotAccount)} />
      @@ -733,7 +741,7 @@ export class Settings extends Component { className="form-check-label" htmlFor="user-show-bot-accounts" > - {i18n.t("show_bot_accounts")} + {I18NextService.i18n.t("show_bot_accounts")}
@@ -750,7 +758,7 @@ export class Settings extends Component { className="form-check-label" htmlFor="user-show-read-posts" > - {i18n.t("show_read_posts")} + {I18NextService.i18n.t("show_read_posts")}
@@ -767,7 +775,7 @@ export class Settings extends Component { className="form-check-label" htmlFor="user-show-new-post-notifs" > - {i18n.t("show_new_post_notifs")} + {I18NextService.i18n.t("show_new_post_notifs")}
@@ -790,7 +798,7 @@ export class Settings extends Component { className="form-check-label" htmlFor="user-send-notifications-to-email" > - {i18n.t("send_notifications_to_email")} + {I18NextService.i18n.t("send_notifications_to_email")} @@ -800,7 +808,7 @@ export class Settings extends Component { {this.state.saveRes.state === "loading" ? ( ) : ( - capitalizeFirstLetter(i18n.t("save")) + capitalizeFirstLetter(I18NextService.i18n.t("save")) )} @@ -813,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")) )} )} @@ -876,7 +884,7 @@ export class Settings extends Component { onChange={linkEvent(this, this.handleGenerateTotp)} /> @@ -886,7 +894,7 @@ export class Settings extends Component { <>
@@ -901,7 +909,7 @@ export class Settings extends Component { onChange={linkEvent(this, this.handleRemoveTotp)} />
@@ -1050,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)); } @@ -1078,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) @@ -1165,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); } @@ -1189,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 });