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) + ) );