mirror of
https://github.com/wassname/talk.git
synced 2026-07-13 15:04:33 +08:00
review: applied some review changes
This commit is contained in:
@@ -9,7 +9,7 @@ import {
|
||||
} from "talk-server/graph/tenant/schema/__generated__/types";
|
||||
import {
|
||||
ACTION_ITEM_TYPE,
|
||||
retrieveManyAuthoredActionPresence,
|
||||
retrieveManyUserActionPresence,
|
||||
} from "talk-server/models/actions";
|
||||
import {
|
||||
retrieveCommentAssetConnection,
|
||||
@@ -21,9 +21,9 @@ export default (ctx: Context) => ({
|
||||
comment: new DataLoader((ids: string[]) =>
|
||||
retrieveManyComments(ctx.mongo, ctx.tenant.id, ids)
|
||||
),
|
||||
retrieveAuthoredActionPresence: new DataLoader<string, GQLActionPresence>(
|
||||
retrieveMyActionPresence: new DataLoader<string, GQLActionPresence>(
|
||||
(itemIDs: string[]) =>
|
||||
retrieveManyAuthoredActionPresence(
|
||||
retrieveManyUserActionPresence(
|
||||
ctx.mongo,
|
||||
ctx.tenant.id,
|
||||
// This should only ever be accessed when a user is logged in.
|
||||
|
||||
@@ -19,8 +19,10 @@ const Comment: GQLCommentTypeResolver<Comment> = {
|
||||
replies: (comment, input, ctx) =>
|
||||
ctx.loaders.Comments.forParent(comment.asset_id, comment.id, input),
|
||||
actionCounts: comment => decodeActionCounts(comment.action_counts),
|
||||
authoredActionPresence: (comment, input, ctx) =>
|
||||
ctx.loaders.Comments.retrieveAuthoredActionPresence.load(comment.id),
|
||||
myActionPresence: (comment, input, ctx) =>
|
||||
ctx.user
|
||||
? ctx.loaders.Comments.retrieveMyActionPresence.load(comment.id)
|
||||
: null,
|
||||
};
|
||||
|
||||
export default Comment;
|
||||
|
||||
@@ -833,10 +833,10 @@ type Comment {
|
||||
actionCounts: ActionCounts!
|
||||
|
||||
"""
|
||||
authoredActionPresence stores the presense information for all the actions
|
||||
myActionPresence stores the presense information for all the actions
|
||||
left by the current User on this Comment.
|
||||
"""
|
||||
authoredActionPresence: ActionPresence! @auth
|
||||
myActionPresence: ActionPresence
|
||||
}
|
||||
|
||||
type PageInfo {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import Joi from "joi";
|
||||
import { pick } from "lodash";
|
||||
import { camelCase, pick } from "lodash";
|
||||
import { Db } from "mongodb";
|
||||
import uuid from "uuid";
|
||||
|
||||
@@ -190,10 +190,10 @@ export async function createActions(
|
||||
}
|
||||
|
||||
/**
|
||||
* retrieveManyAuthoredActionPresence returns the action presence for a specific
|
||||
* retrieveManyUserActionPresence returns the action presence for a specific
|
||||
* user.
|
||||
*/
|
||||
export async function retrieveManyAuthoredActionPresence(
|
||||
export async function retrieveManyUserActionPresence(
|
||||
mongo: Db,
|
||||
tenantID: string,
|
||||
userID: string | null,
|
||||
@@ -226,7 +226,7 @@ export async function retrieveManyAuthoredActionPresence(
|
||||
itemActions.reduce(
|
||||
(actionPresence, { action_type }) => ({
|
||||
...actionPresence,
|
||||
[action_type.toLowerCase()]: true,
|
||||
[camelCase(action_type)]: true,
|
||||
}),
|
||||
{
|
||||
reaction: false,
|
||||
|
||||
Reference in New Issue
Block a user