X-Git-Url: http://these/git/?a=blobdiff_plain;f=src%2Fshared%2Fcomponents%2Fperson%2Fpassword-change.tsx;h=565f55e6ce2853d0be7c6e53bf294d2a163a0632;hb=c3ab9e74f8775f4b811866d2675b00f9702bde3d;hp=8120fe97630e67d60a972b9103fdeb4d5071a7e7;hpb=cc90ded31ed5d7d1b61474872481824113f0933b;p=lemmy-ui.git diff --git a/src/shared/components/person/password-change.tsx b/src/shared/components/person/password-change.tsx index 8120fe9..565f55e 100644 --- a/src/shared/components/person/password-change.tsx +++ b/src/shared/components/person/password-change.tsx @@ -1,81 +1,55 @@ -import { None } from "@sniptt/monads"; +import { myAuth, setIsoData } from "@utils/app"; +import { capitalizeFirstLetter } from "@utils/helpers"; import { Component, linkEvent } from "inferno"; -import { - GetSiteResponse, - LoginResponse, - PasswordChange as PasswordChangeForm, - UserOperation, - wsJsonToRes, - wsUserOp, -} from "lemmy-js-client"; -import { Subscription } from "rxjs"; -import { i18n } from "../../i18next"; -import { UserService, WebSocketService } from "../../services"; -import { - capitalizeFirstLetter, - isBrowser, - setIsoData, - toast, - wsClient, - wsSubscribe, -} from "../../utils"; +import { GetSiteResponse, LoginResponse } from "lemmy-js-client"; +import { HttpService, I18NextService, UserService } from "../../services"; +import { RequestState } from "../../services/HttpService"; import { HtmlTags } from "../common/html-tags"; import { Spinner } from "../common/icon"; interface State { - passwordChangeForm: PasswordChangeForm; - loading: boolean; + passwordChangeRes: RequestState; + form: { + token: string; + password?: string; + password_verify?: string; + }; siteRes: GetSiteResponse; } export class PasswordChange extends Component { private isoData = setIsoData(this.context); - private subscription: Subscription; - emptyState: State = { - passwordChangeForm: new PasswordChangeForm({ - token: this.props.match.params.token, - password: undefined, - password_verify: undefined, - }), - loading: false, + state: State = { + passwordChangeRes: { state: "empty" }, siteRes: this.isoData.site_res, + form: { + token: this.props.match.params.token, + }, }; constructor(props: any, context: any) { super(props, context); - - this.state = this.emptyState; - - this.parseMessage = this.parseMessage.bind(this); - this.subscription = wsSubscribe(this.parseMessage); - } - - componentWillUnmount() { - if (isBrowser()) { - this.subscription.unsubscribe(); - } } get documentTitle(): string { - return this.state.siteRes.site_view.match({ - some: siteView => `${i18n.t("password_change")} - ${siteView.site.name}`, - none: "", - }); + return `${I18NextService.i18n.t("password_change")} - ${ + this.state.siteRes.site_view.site.name + }`; } render() { return ( -
+
-
-
-
{i18n.t("password_change")}
+
+
+

+ {I18NextService.i18n.t("password_change")} +

{this.passwordChangeForm()}
@@ -86,45 +60,45 @@ export class PasswordChange extends Component { passwordChangeForm() { return (
-
-