1 import { Component } from "inferno";
5 VerifyEmail as VerifyEmailForm,
9 } from "lemmy-js-client";
10 import { Subscription } from "rxjs";
11 import { i18n } from "../../i18next";
12 import { WebSocketService } from "../../services";
20 import { HtmlTags } from "../common/html-tags";
23 verifyEmailForm: VerifyEmailForm;
24 siteRes: GetSiteResponse;
27 export class VerifyEmail extends Component<any, State> {
28 private isoData = setIsoData(this.context);
29 private subscription?: Subscription;
33 token: this.props.match.params.token,
35 siteRes: this.isoData.site_res,
38 constructor(props: any, context: any) {
39 super(props, context);
41 this.parseMessage = this.parseMessage.bind(this);
42 this.subscription = wsSubscribe(this.parseMessage);
46 WebSocketService.Instance.send(
47 wsClient.verifyEmail(this.state.verifyEmailForm)
51 componentWillUnmount() {
53 this.subscription?.unsubscribe();
57 get documentTitle(): string {
58 return `${i18n.t("verify_email")} - ${
59 this.state.siteRes.site_view.site.name
65 <div className="container-lg">
67 title={this.documentTitle}
68 path={this.context.router.route.match.url}
71 <div className="col-12 col-lg-6 offset-lg-3 mb-4">
72 <h5>{i18n.t("verify_email")}</h5>
79 parseMessage(msg: any) {
80 let op = wsUserOp(msg);
83 toast(i18n.t(msg.error), "danger");
84 this.setState(this.state);
85 this.props.history.push("/");
87 } else if (op == UserOperation.VerifyEmail) {
88 let data = wsJsonToRes<VerifyEmailResponse>(msg);
90 toast(i18n.t("email_verified"));
91 this.props.history.push("/login");