- i.audio.addEventListener("ended", () => {
- i.audio.currentTime = 0;
- i.setState({ captchaPlaying: false });
- });
- },
- none: void 0,
- }),
- none: void 0,
- });
- }
-
- captchaPngSrc(captcha: CaptchaResponse) {
- return `data:image/png;base64,${captcha.png}`;
- }
-
- parseMessage(msg: any) {
- let op = wsUserOp(msg);
- console.log(msg);
- if (msg.error) {
- toast(i18n.t(msg.error), "danger");
- this.setState(this.emptyState);
- this.setState(s => ((s.registerForm.captcha_answer = undefined), s));
- // Refetch another captcha
- // WebSocketService.Instance.send(wsClient.getCaptcha());
- return;
- } else {
- if (op == UserOperation.Register) {
- let data = wsJsonToRes<LoginResponse>(msg, LoginResponse);
- this.setState(this.emptyState);
- // Only log them in if a jwt was set
- if (data.jwt.isSome()) {
- UserService.Instance.login(data);
- this.props.history.push("/communities");
- location.reload();
- } else {
- if (data.verify_email_sent) {
- toast(i18n.t("verify_email_sent"));
+ i.audio.addEventListener("ended", () => {
+ if (i.audio) {
+ i.audio.currentTime = 0;
+ i.setState({ captchaPlaying: false });