From 56dedb551f4c8bf88c04a0b0aec7a01db259f082 Mon Sep 17 00:00:00 2001 From: gaba Date: Tue, 11 Apr 2017 15:02:04 -0700 Subject: [PATCH 1/5] Adds click to showAll and refresh query to the '# comments' tab. --- client/coral-embed-stream/src/Embed.js | 8 +++++++- client/coral-plugin-comment-count/CommentCount.js | 4 ++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/client/coral-embed-stream/src/Embed.js b/client/coral-embed-stream/src/Embed.js index d9b5c8310..4df0290ac 100644 --- a/client/coral-embed-stream/src/Embed.js +++ b/client/coral-embed-stream/src/Embed.js @@ -144,7 +144,13 @@ class Embed extends Component {
- + { + this.props.viewAllComments(); + this.props.data.refetch(); + }}/> + {lang.t('MY_COMMENTS')} Configure Stream diff --git a/client/coral-plugin-comment-count/CommentCount.js b/client/coral-plugin-comment-count/CommentCount.js index 764984634..e53944025 100644 --- a/client/coral-plugin-comment-count/CommentCount.js +++ b/client/coral-plugin-comment-count/CommentCount.js @@ -3,8 +3,8 @@ import {I18n} from '../coral-framework'; import translations from './translations.json'; const name = 'coral-plugin-comment-count'; -const CommentCount = ({count}) => { - return
+const CommentCount = ({count, onClick}) => { + return
onClick()}> {`${count} ${count === 1 ? lang.t('comment') : lang.t('comment-plural')}`}
; }; From f900727455521a03271f08172343ea53e975fd48 Mon Sep 17 00:00:00 2001 From: gaba Date: Tue, 11 Apr 2017 17:57:56 -0700 Subject: [PATCH 2/5] Move the method to the class, changes name and removes wrapper. --- client/coral-embed-stream/src/Embed.js | 25 +++++++++++++------ .../CommentCount.js | 4 +-- 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/client/coral-embed-stream/src/Embed.js b/client/coral-embed-stream/src/Embed.js index 4df0290ac..aa4223757 100644 --- a/client/coral-embed-stream/src/Embed.js +++ b/client/coral-embed-stream/src/Embed.js @@ -1,4 +1,4 @@ -import React, {Component} from 'react'; +import React from 'react'; import {compose} from 'react-apollo'; import {connect} from 'react-redux'; import isEqual from 'lodash/isEqual'; @@ -36,9 +36,18 @@ import HighlightedComment from './Comment'; import LoadMore from './LoadMore'; import NewCount from './NewCount'; -class Embed extends Component { +class Embed extends React.Component { - state = {activeTab: 0, showSignInDialog: false, activeReplyBox: ''}; + constructor(props) { + super(props); + this.state = { + activeTab: 0, + showSignInDialog: + false, activeReplyBox: '' + }; + + this.handleClick = this.handleClick.bind(this); + } changeTab = (tab) => { const {isAdmin} = this.props.auth; @@ -114,6 +123,11 @@ class Embed extends Component { } } + handleClick() { + this.props.viewAllComments(); + this.props.data.refetch(); + } + render () { const {activeTab} = this.state; const {closedAt, countCache = {}} = this.props.asset; @@ -146,10 +160,7 @@ class Embed extends Component { { - this.props.viewAllComments(); - this.props.data.refetch(); - }}/> + handleClick={this.handleClick}/> {lang.t('MY_COMMENTS')} Configure Stream diff --git a/client/coral-plugin-comment-count/CommentCount.js b/client/coral-plugin-comment-count/CommentCount.js index e53944025..be38d1425 100644 --- a/client/coral-plugin-comment-count/CommentCount.js +++ b/client/coral-plugin-comment-count/CommentCount.js @@ -3,8 +3,8 @@ import {I18n} from '../coral-framework'; import translations from './translations.json'; const name = 'coral-plugin-comment-count'; -const CommentCount = ({count, onClick}) => { - return
onClick()}> +const CommentCount = ({count, handleClick}) => { + return
{`${count} ${count === 1 ? lang.t('comment') : lang.t('comment-plural')}`}
; }; From f4f8e5053f1a0d59d040631c687fe7cb536a0e5c Mon Sep 17 00:00:00 2001 From: gaba Date: Wed, 12 Apr 2017 10:11:21 -0700 Subject: [PATCH 3/5] Remove the binding in the constructor. --- client/coral-embed-stream/src/Embed.js | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/client/coral-embed-stream/src/Embed.js b/client/coral-embed-stream/src/Embed.js index aa4223757..453d645c2 100644 --- a/client/coral-embed-stream/src/Embed.js +++ b/client/coral-embed-stream/src/Embed.js @@ -42,11 +42,9 @@ class Embed extends React.Component { super(props); this.state = { activeTab: 0, - showSignInDialog: - false, activeReplyBox: '' + showSignInDialog: false, + activeReplyBox: '' }; - - this.handleClick = this.handleClick.bind(this); } changeTab = (tab) => { @@ -123,7 +121,7 @@ class Embed extends React.Component { } } - handleClick() { + handleClick = () => { this.props.viewAllComments(); this.props.data.refetch(); } From 48795b29bf600810a7d3cca01fe982c16c877862 Mon Sep 17 00:00:00 2001 From: gaba Date: Wed, 12 Apr 2017 10:40:15 -0700 Subject: [PATCH 4/5] Removes isAdmin for refetching when changing tabs. --- client/coral-embed-stream/src/Embed.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/client/coral-embed-stream/src/Embed.js b/client/coral-embed-stream/src/Embed.js index 453d645c2..342e490ea 100644 --- a/client/coral-embed-stream/src/Embed.js +++ b/client/coral-embed-stream/src/Embed.js @@ -48,10 +48,10 @@ class Embed extends React.Component { } changeTab = (tab) => { - const {isAdmin} = this.props.auth; // Everytime the comes from another tab, the Stream needs to be updated. - if (tab === 0 && isAdmin) { + if (tab === 0) { + this.props.viewAllComments(); this.props.data.refetch(); } From cbde4cc8bc4031283202b646452e38d522589222 Mon Sep 17 00:00:00 2001 From: gaba Date: Wed, 12 Apr 2017 11:58:41 -0700 Subject: [PATCH 5/5] Removes handleClick as it is working now with the changeTab (as the viewAllComments was added). /cc @kiwi --- client/coral-embed-stream/src/Embed.js | 9 +-------- client/coral-plugin-comment-count/CommentCount.js | 4 ++-- 2 files changed, 3 insertions(+), 10 deletions(-) diff --git a/client/coral-embed-stream/src/Embed.js b/client/coral-embed-stream/src/Embed.js index 342e490ea..db9c76000 100644 --- a/client/coral-embed-stream/src/Embed.js +++ b/client/coral-embed-stream/src/Embed.js @@ -121,11 +121,6 @@ class Embed extends React.Component { } } - handleClick = () => { - this.props.viewAllComments(); - this.props.data.refetch(); - } - render () { const {activeTab} = this.state; const {closedAt, countCache = {}} = this.props.asset; @@ -156,9 +151,7 @@ class Embed extends React.Component {
- + {lang.t('MY_COMMENTS')} Configure Stream diff --git a/client/coral-plugin-comment-count/CommentCount.js b/client/coral-plugin-comment-count/CommentCount.js index be38d1425..764984634 100644 --- a/client/coral-plugin-comment-count/CommentCount.js +++ b/client/coral-plugin-comment-count/CommentCount.js @@ -3,8 +3,8 @@ import {I18n} from '../coral-framework'; import translations from './translations.json'; const name = 'coral-plugin-comment-count'; -const CommentCount = ({count, handleClick}) => { - return
+const CommentCount = ({count}) => { + return
{`${count} ${count === 1 ? lang.t('comment') : lang.t('comment-plural')}`}
; };