fix(core): list comment changes usage (#13036)

fix AF-2710

#### PR Dependency Tree


* **PR #13036** 👈

This tree was auto-generated by
[Charcoal](https://github.com/danerwilliams/charcoal)

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

* **Style**
* Limited the maximum width of the comment input container to 800 pixels
for improved layout consistency.

* **New Features**
* Enhanced comment change listings to include pagination information,
allowing users to navigate through comment changes more effectively.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->

Co-authored-by: fengmk2 <fengmk2@gmail.com>
This commit is contained in:
Peng Xiao
2025-07-04 19:02:09 +08:00
committed by GitHub
parent 2f9a96f1c5
commit 1452f77c85
4 changed files with 32 additions and 13 deletions

View File

@@ -172,6 +172,7 @@ export const commentInputContainer = style({
justifyContent: 'flex-start', justifyContent: 'flex-start',
gap: '4px', gap: '4px',
paddingLeft: '8px', paddingLeft: '8px',
maxWidth: '800px',
}); });
export const userName = style({ export const userName = style({

View File

@@ -149,15 +149,25 @@ export class DocCommentStore extends Entity<{
const commentChanges = response.workspace?.commentChanges; const commentChanges = response.workspace?.commentChanges;
if (!commentChanges) { if (!commentChanges) {
return []; return {
changes: [],
startCursor: '',
endCursor: after ?? '',
hasNextPage: false,
};
} }
return commentChanges.edges.map(edge => ({ return {
id: edge.node.id, changes: commentChanges.edges.map(edge => ({
action: edge.node.action, id: edge.node.id,
comment: normalizeComment(edge.node.item), action: edge.node.action,
commentId: edge.node.commentId || undefined, comment: normalizeComment(edge.node.item),
})); commentId: edge.node.commentId || undefined,
})),
startCursor: commentChanges.pageInfo.startCursor || '',
endCursor: commentChanges.pageInfo.endCursor || '',
hasNextPage: commentChanges.pageInfo.hasNextPage,
};
} }
async createComment(commentInput: { async createComment(commentInput: {

View File

@@ -359,13 +359,15 @@ export class DocCommentEntity extends Entity<{
// If we have comments, fetch changes; otherwise fetch all // If we have comments, fetch changes; otherwise fetch all
if (this.comments$.value.length > 0) { if (this.comments$.value.length > 0) {
return fromPromise(async () => { return fromPromise(async () => {
return await this.store.listCommentChanges({ const res = await this.store.listCommentChanges({
after: this.startCursor, after: this.startCursor,
}); });
return res;
}).pipe( }).pipe(
tap(changes => { tap(result => {
if (changes) { if (result) {
this.handleCommentChanges(changes); this.handleCommentChanges(result);
this.startCursor = result.endCursor;
} }
}), }),
catchError(error => { catchError(error => {
@@ -418,7 +420,8 @@ export class DocCommentEntity extends Entity<{
} }
} }
private handleCommentChanges(changes: DocCommentChangeListResult): void { private handleCommentChanges(result: DocCommentChangeListResult): void {
const { changes } = result;
if (!changes || changes.length === 0) { if (!changes || changes.length === 0) {
return; return;
} }

View File

@@ -51,4 +51,9 @@ export interface DocCommentChange {
commentId?: CommentId; // a change with comment id is a reply commentId?: CommentId; // a change with comment id is a reply
} }
export type DocCommentChangeListResult = DocCommentChange[]; export type DocCommentChangeListResult = {
changes: DocCommentChange[];
startCursor: string;
endCursor: string;
hasNextPage: boolean;
};