Skip to content

Commit

Permalink
fix: display captcha correctly on initial load (#162)
Browse files Browse the repository at this point in the history
修复首次加载评论时,不能正常显示验证码的问题。

Fixes #160

/kind bug

```release-note
修复首次加载评论时,不能正常显示验证码的问题。
```
  • Loading branch information
ruibaby authored Oct 28, 2024
1 parent 3ab7d2f commit db660bb
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion packages/comment-widget/src/base-form.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,19 @@ export class BaseForm extends LitElement {
return this.captchaEnabled && !this.currentUser && this.allowAnonymousComments;
}

// eslint-disable-next-line @typescript-eslint/no-explicit-any
override updated(changedProperties: Map<string, any>) {
if (
changedProperties.has('captchaEnabled') ||
changedProperties.has('currentUser') ||
changedProperties.has('allowAnonymousComments')
) {
if (this.showCaptcha) {
this.handleFetchCaptcha();
}
}
}

async handleFetchCaptcha() {
if (!this.showCaptcha) {
return;
Expand Down Expand Up @@ -143,7 +156,6 @@ export class BaseForm extends LitElement {
override connectedCallback(): void {
super.connectedCallback();
this.addEventListener('keydown', this.onKeydown);
this.handleFetchCaptcha();
}

override disconnectedCallback(): void {
Expand Down

0 comments on commit db660bb

Please sign in to comment.