1 import { Component } from "inferno";
5 VerifyEmail as VerifyEmailForm,
7 } from "lemmy-js-client";
8 import { Subscription } from "rxjs";
9 import { i18n } from "../../i18next";
10 import { WebSocketService } from "../../services";
20 import { HtmlTags } from "../common/html-tags";
23 verifyEmailForm: VerifyEmailForm;
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 site_view: this.isoData.site_res.site_view,
38 constructor(props: any, context: any) {
39 super(props, context);
41 this.state = this.emptyState;
43 this.parseMessage = this.parseMessage.bind(this);
44 this.subscription = wsSubscribe(this.parseMessage);
48 WebSocketService.Instance.send(
49 wsClient.verifyEmail(this.state.verifyEmailForm)
53 componentWillUnmount() {
55 this.subscription.unsubscribe();
59 get documentTitle(): string {
60 return `${i18n.t("verify_email")} - ${this.state.site_view.site.name}`;
65 <div class="container">
67 title={this.documentTitle}
68 path={this.context.router.route.match.url}
71 <div class="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).data;
90 toast(i18n.t("email_verified"));
91 this.state = this.emptyState;
92 this.setState(this.state);
93 this.props.history.push("/login");