Skip to content

Commit

Permalink
fix: wrong reply size (#117)
Browse files Browse the repository at this point in the history
如果开启了 `同时加载评论的回复`,然后异步加载下一页回复时,改为使用 `同时加载回复的条数` 的值,如果和以前一样的 `默认加载回复条数` 选项作为 size 参数,那么可能出现无法正确获取下一页数据的问题。

Fixes #114

```release-note
修复开启 `同时加载回复的条数` 选项时,可能无法正确加载下一页的问题
```
  • Loading branch information
ruibaby committed Apr 29, 2024
1 parent f04fb71 commit 220219d
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Expand Up @@ -41,5 +41,5 @@ build {
}

halo {
version = "2.14.0"
version = "2.15.0-rc.1"
}
12 changes: 9 additions & 3 deletions packages/comment-widget/src/comment-replies.ts
Expand Up @@ -92,7 +92,7 @@ export class CommentReplies extends LitElement {
this.page = 1;
}

const queryParams = [`page=${this.page || 0}`, `size=${this.replySize}`];
const queryParams = [`page=${this.page || 1}`, `size=${this.replySize}`];

const response = await fetch(
`${this.baseUrl}/apis/api.halo.run/v1alpha1/comments/${this.comment?.metadata.name}/reply?${queryParams.join('&')}`
Expand Down Expand Up @@ -122,8 +122,14 @@ export class CommentReplies extends LitElement {
}

async fetchNext() {
this.page++;
await this.fetchReplies({ append: true });
if (this.withReplies) {
// if withReplies is true, we need to reload the replies list
await this.fetchReplies({ append: !(this.page === 1) });
this.page++;
} else {
this.page++;
await this.fetchReplies({ append: true });
}
}

override connectedCallback(): void {
Expand Down
4 changes: 2 additions & 2 deletions src/main/resources/extensions/settings.yaml
Expand Up @@ -8,12 +8,12 @@ spec:
label: 基本设置
formSchema:
- $formkit: number
label: 默认加载评论条数
label: 评论分页条数
name: size
validation: required
value: 20
- $formkit: number
label: 默认加载回复条数
label: 回复分页条数
name: replySize
validation: required
value: 10
Expand Down

0 comments on commit 220219d

Please sign in to comment.