[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:
Kiwi
2018-10-12 16:41:58 +00:00
committed by Wyatt Johnson
parent ff5a94b91f
commit cf2be96a13
62 changed files with 9063 additions and 5981 deletions
@@ -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";