mirror of
https://github.com/wassname/talk.git
synced 2026-07-16 11:22:16 +08:00
[next] Bugfixes (#2272)
* feat: suspending, banning, now propogation * feat: new mutation api with hooks support * [CORL-343] Center Spinner in Stream * [CORL-344] Fix moderation card styling * [CORL-338] Fix permalink reply bug * [CORL-337] Fix community guidelines box width * [CORL-341] Toggle reply form view when clicking on reply * test: add tests * [CORL-333] Fix bug: removing message box icon; [CORL-336] Fix bug: allow resetting custom css
This commit is contained in:
@@ -1,33 +1,48 @@
|
||||
export function denormalizeComment(comment: any, parents: any[] = []) {
|
||||
const replyNodes =
|
||||
import { GQLComment, GQLCommentEdge, GQLStory } from "talk-framework/schema";
|
||||
|
||||
import createFixture, { Fixture } from "./createFixture";
|
||||
|
||||
export function denormalizeComment(
|
||||
comment: Fixture<GQLComment>,
|
||||
parents: Array<Fixture<GQLCommentEdge>> = []
|
||||
): GQLComment {
|
||||
const replyEdges =
|
||||
(comment.replies &&
|
||||
comment.replies.edges.map((edge: any) =>
|
||||
denormalizeComment(edge, [...parents, comment])
|
||||
)) ||
|
||||
comment.replies.edges &&
|
||||
comment.replies.edges.map(edge => ({
|
||||
...edge,
|
||||
node:
|
||||
edge.node &&
|
||||
denormalizeComment(edge.node, [
|
||||
...parents,
|
||||
{ node: comment, cursor: comment.createdAt },
|
||||
]),
|
||||
}))) ||
|
||||
[];
|
||||
const repliesPageInfo = (comment.replies && comment.replies.pageInfo) || {
|
||||
endCursor: null,
|
||||
hasNextPage: false,
|
||||
};
|
||||
return {
|
||||
return createFixture<GQLComment>({
|
||||
...comment,
|
||||
replies: { edges: replyNodes, pageInfo: repliesPageInfo },
|
||||
replyCount: replyNodes.length,
|
||||
replies: { edges: replyEdges, pageInfo: repliesPageInfo },
|
||||
replyCount: replyEdges.length,
|
||||
parentCount: parents.length,
|
||||
parents: {
|
||||
edges: parents,
|
||||
pageInfo: { startCursor: null, hasPreviousPage: false },
|
||||
},
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
export function denormalizeComments(commentList: any[]) {
|
||||
export function denormalizeComments(commentList: Array<Fixture<GQLComment>>) {
|
||||
return commentList.map(c => denormalizeComment(c));
|
||||
}
|
||||
|
||||
export function denormalizeStory(story: any) {
|
||||
export function denormalizeStory(story: Fixture<GQLStory>) {
|
||||
const commentNodes =
|
||||
(story.comments &&
|
||||
story.comments.edges &&
|
||||
story.comments.edges.map((edge: any) => ({
|
||||
...edge,
|
||||
node: denormalizeComment(edge.node),
|
||||
@@ -46,6 +61,6 @@ export function denormalizeStory(story: any) {
|
||||
};
|
||||
}
|
||||
|
||||
export function denormalizeStories(storyList: any[]) {
|
||||
export function denormalizeStories(storyList: Array<Fixture<GQLStory>>) {
|
||||
return storyList.map(a => denormalizeStory(a));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user