mirror of
https://github.com/wassname/talk.git
synced 2026-08-03 13:20:59 +08:00
[next] Permalink View (#1987)
* feat: Implement converation thread * Update unit tests * test: adapt integration tests * test: refactor denormalization helpers * test: Include multiple parents in permalink View * test: add integration test for loading previous parent comments * feat: use dashed & solid time line * feat: use new conversation thread design * feat: add header from new design * test: update snapshots * fix: better scrolling behavior * feat: add user box * fix: add translations * fix: typo * fix: plural translation * fix: paddings * feat: better styling for level 0 comments * fix: gutter size * fix: update iframe url with new comment id * test: add unit tests
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
export function denormalizeComment(comment: any, parents: any[] = []) {
|
||||
const replyNodes =
|
||||
(comment.replies &&
|
||||
comment.replies.edges.map((edge: any) =>
|
||||
denormalizeComment(edge, [...parents, comment])
|
||||
)) ||
|
||||
[];
|
||||
const repliesPageInfo = (comment.replies && comment.replies.pageInfo) || {
|
||||
endCursor: null,
|
||||
hasNextPage: false,
|
||||
};
|
||||
return {
|
||||
...comment,
|
||||
replies: { edges: replyNodes, pageInfo: repliesPageInfo },
|
||||
replyCount: replyNodes.length,
|
||||
parentCount: parents.length,
|
||||
parents: {
|
||||
edges: parents,
|
||||
pageInfo: { startCursor: null, hasPreviousPage: false },
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
export function denormalizeComments(commentList: any[]) {
|
||||
return commentList.map(c => denormalizeComment(c));
|
||||
}
|
||||
|
||||
export function denormalizeAsset(asset: any) {
|
||||
const commentNodes =
|
||||
(asset.comments &&
|
||||
asset.comments.edges.map((edge: any) => denormalizeComment(edge))) ||
|
||||
[];
|
||||
const commentsPageInfo = (asset.comments && asset.comments.pageInfo) || {
|
||||
endCursor: null,
|
||||
hasNextPage: false,
|
||||
};
|
||||
return {
|
||||
...asset,
|
||||
comments: { edges: commentNodes, pageInfo: commentsPageInfo },
|
||||
commentCounts: {
|
||||
totalVisible: commentNodes.length,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
export function denormalizeAssets(assetList: any[]) {
|
||||
return assetList.map(a => denormalizeAsset(a));
|
||||
}
|
||||
@@ -9,3 +9,4 @@ export {
|
||||
NoFragmentRefs,
|
||||
} from "./removeFragmentRefs";
|
||||
export { default as createUUIDGenerator } from "./createUUIDGenerator";
|
||||
export * from "./denormalize";
|
||||
|
||||
Reference in New Issue
Block a user