mirror of
https://github.com/wassname/talk.git
synced 2026-07-28 11:27:05 +08:00
[CORL-181] Comment Count Injection (#2581)
* feat: inject comment counts * fix: tests * feat: integrate stream embed with coral counts * chore: refactor constants * test: test for count bundle * test: test live comment count integration with stream embed * feat: use defer * fix: snapshot * feat: auto add count.js in when calling Coral.createStreamEmbed * fix: tests * fix: rm duplicate test * chore: remove unuse file
This commit is contained in:
@@ -1,14 +1,14 @@
|
||||
import { GQLCommentCountsTypeResolver } from "coral-server/graph/tenant/schema/__generated__/types";
|
||||
import { PUBLISHED_STATUSES } from "coral-server/models/comment/constants";
|
||||
import { Story } from "coral-server/models/story";
|
||||
import {
|
||||
calculateTotalPublishedCommentCount,
|
||||
Story,
|
||||
} from "coral-server/models/story";
|
||||
|
||||
export type CommentCountsInput = Pick<Story, "commentCounts" | "id">;
|
||||
|
||||
export const CommentCounts: GQLCommentCountsTypeResolver<CommentCountsInput> = {
|
||||
totalPublished: ({ commentCounts }) =>
|
||||
PUBLISHED_STATUSES.reduce(
|
||||
(total, status) => total + commentCounts.status[status],
|
||||
0
|
||||
),
|
||||
calculateTotalPublishedCommentCount(commentCounts.status),
|
||||
statuses: ({ commentCounts }) => commentCounts.status,
|
||||
tags: (s, input, ctx) => ctx.loaders.Comments.tagCounts.load(s.id),
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user