From 6475f0c0f6d298b9fc1b6c73196f631e1e29b7ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bel=C3=A9n=20Curcio?= Date: Tue, 25 Sep 2018 19:27:30 -0300 Subject: [PATCH] Testing my actionPresence --- src/core/client/stream/mutations/index.ts | 4 ++ .../containers/RespectButtonContainer.tsx | 45 +++++++++++++------ 2 files changed, 35 insertions(+), 14 deletions(-) diff --git a/src/core/client/stream/mutations/index.ts b/src/core/client/stream/mutations/index.ts index 853d2d824..17c8712e9 100644 --- a/src/core/client/stream/mutations/index.ts +++ b/src/core/client/stream/mutations/index.ts @@ -35,3 +35,7 @@ export { CreateCommentReactionMutation, CreateCommentReactionInput, } from "./CreateCommentReactionMutation"; +export { + withDeleteCommentReactionMutation, + DeleteCommentReactionMutation, +} from "./DeleteCommentReactionMutation"; diff --git a/src/core/client/stream/tabs/comments/containers/RespectButtonContainer.tsx b/src/core/client/stream/tabs/comments/containers/RespectButtonContainer.tsx index e5c26d273..6f816a335 100644 --- a/src/core/client/stream/tabs/comments/containers/RespectButtonContainer.tsx +++ b/src/core/client/stream/tabs/comments/containers/RespectButtonContainer.tsx @@ -5,22 +5,34 @@ import { RespectButtonContainer_comment as CommentData } from "talk-stream/__gen import { CreateCommentReactionMutation, + DeleteCommentReactionMutation, withCreateCommentReactionMutation, + withDeleteCommentReactionMutation, } from "../../../mutations"; import RespectButton from "../components/RespectButton"; interface RespectButtonContainerProps { createCommentReaction: CreateCommentReactionMutation; + deleteCommentReaction: DeleteCommentReactionMutation; comment: CommentData; } class RespectButtonContainer extends React.Component< RespectButtonContainerProps > { - private onButtonClick = () => - this.props.createCommentReaction({ + private onButtonClick = () => { + const input = { commentID: this.props.comment.id, - }); + }; + + // const { createCommentReaction, deleteCommentReaction } = this.props; + // const { myActionPresence } = this.props.comment; + + // return myActionPresence + // ? deleteCommentReaction(input) + // : createCommentReaction(input); + return this.props.createCommentReaction(input); + }; public render() { const { actionCounts: { @@ -31,17 +43,22 @@ class RespectButtonContainer extends React.Component< } } -export default withCreateCommentReactionMutation( - withFragmentContainer({ - comment: graphql` - fragment RespectButtonContainer_comment on Comment { - id - actionCounts { - reaction { - total +export default withDeleteCommentReactionMutation( + withCreateCommentReactionMutation( + withFragmentContainer({ + comment: graphql` + fragment RespectButtonContainer_comment on Comment { + id + actionCounts { + reaction { + total + } + } + myActionPresence { + reaction } } - } - `, - })(RespectButtonContainer) + `, + })(RespectButtonContainer) + ) );