From bba4474858b136e9296a83cb441f98e2dc67a18a Mon Sep 17 00:00:00 2001 From: A Lawliet Date: Thu, 22 Jun 2017 01:51:06 -0400 Subject: [PATCH 1/4] Search dropdown: clear search when closed --- .../Moderation/components/StorySearch.js | 4 +-- .../Moderation/containers/StorySearch.js | 26 +++++++++++++++---- 2 files changed, 23 insertions(+), 7 deletions(-) diff --git a/client/coral-admin/src/routes/Moderation/components/StorySearch.js b/client/coral-admin/src/routes/Moderation/components/StorySearch.js index 5fe82fa97..b58940ea7 100644 --- a/client/coral-admin/src/routes/Moderation/components/StorySearch.js +++ b/client/coral-admin/src/routes/Moderation/components/StorySearch.js @@ -81,7 +81,7 @@ const StorySearch = (props) => { -
+
); }; @@ -89,7 +89,7 @@ const StorySearch = (props) => { StorySearch.propTypes = { search: PropTypes.func.isRequired, goToStory: PropTypes.func.isRequired, - closeSearch: PropTypes.func.isRequired, + clearAndCloseSearch: PropTypes.func.isRequired, moderation: PropTypes.object.isRequired, handleSearchChange: PropTypes.func.isRequired, assetId: PropTypes.string diff --git a/client/coral-admin/src/routes/Moderation/containers/StorySearch.js b/client/coral-admin/src/routes/Moderation/containers/StorySearch.js index f4ab6f23e..d9c3b2ef1 100644 --- a/client/coral-admin/src/routes/Moderation/containers/StorySearch.js +++ b/client/coral-admin/src/routes/Moderation/containers/StorySearch.js @@ -13,6 +13,21 @@ class StorySearchContainer extends React.Component { }; } + componentWillUnmount() { + this.props.storySearchChange(''); + } + + clearSearch = () => { + this.setState({searchValue: ''}, () => { + this.search(); + }); + } + + clearAndCloseSearch = () => { + this.clearSearch(); + this.props.closeSearch(); + } + handleSearchChange = (e) => { const {value} = e.target; this.setState({ @@ -23,7 +38,7 @@ class StorySearchContainer extends React.Component { handleEsc = (e) => { if (e.key === 'Escape') { e.preventDefault(); - this.props.closeSearch(); + this.clearAndCloseSearch(); } } @@ -40,15 +55,15 @@ class StorySearchContainer extends React.Component { } goToStory = (id) => { - const {router, closeSearch} = this.props; + const {router} = this.props; router.push(`/admin/moderate/all/${id}`); - closeSearch(); + this.clearAndCloseSearch(); } goToModerateAll = () => { - const {router, closeSearch} = this.props; + const {router} = this.props; router.push('/admin/moderate/all'); - closeSearch(); + this.clearAndCloseSearch(); } render () { @@ -61,6 +76,7 @@ class StorySearchContainer extends React.Component { handleEnter={this.handleEnter} searchValue={this.state.searchValue} handleSearchChange={this.handleSearchChange} + clearAndCloseSearch={this.clearAndCloseSearch} {...this.props} /> ); From c41b3c27bab70e0ac6b906eefb2d6eaab3d45ad1 Mon Sep 17 00:00:00 2001 From: A Lawliet Date: Thu, 22 Jun 2017 10:29:41 -0400 Subject: [PATCH 2/4] Prevent unnecessary render - no need to clear search if already empty, just close dropdown --- .../src/routes/Moderation/containers/StorySearch.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/client/coral-admin/src/routes/Moderation/containers/StorySearch.js b/client/coral-admin/src/routes/Moderation/containers/StorySearch.js index d9c3b2ef1..d5a0ad243 100644 --- a/client/coral-admin/src/routes/Moderation/containers/StorySearch.js +++ b/client/coral-admin/src/routes/Moderation/containers/StorySearch.js @@ -3,6 +3,7 @@ import {compose, gql} from 'react-apollo'; import StorySearch from '../components/StorySearch'; import {withRouter} from 'react-router'; import withQuery from 'coral-framework/hocs/withQuery'; +import {isEmpty} from 'lodash'; class StorySearchContainer extends React.Component { constructor(props) { @@ -24,7 +25,9 @@ class StorySearchContainer extends React.Component { } clearAndCloseSearch = () => { - this.clearSearch(); + if (!isEmpty(this.state.searchValue)) { + this.clearSearch(); + } this.props.closeSearch(); } From 60dd6a37d728e613623859a287dc9d16304740cd Mon Sep 17 00:00:00 2001 From: A Lawliet Date: Thu, 22 Jun 2017 13:44:48 -0400 Subject: [PATCH 3/4] =?UTF-8?q?Fix=20Moderate=20=E2=86=92=20link=20by=20se?= =?UTF-8?q?tting=20to=20"All"=20for=20that=20story?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- client/coral-admin/src/routes/Moderation/components/Comment.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/coral-admin/src/routes/Moderation/components/Comment.js b/client/coral-admin/src/routes/Moderation/components/Comment.js index 3d946f9fc..29ecfb0e7 100644 --- a/client/coral-admin/src/routes/Moderation/components/Comment.js +++ b/client/coral-admin/src/routes/Moderation/components/Comment.js @@ -129,7 +129,7 @@ class Comment extends React.Component {
Story: {comment.asset.title} {!props.currentAsset && - {t('modqueue.moderate')}} + {t('modqueue.moderate')}}
Date: Thu, 22 Jun 2017 14:32:49 -0600 Subject: [PATCH 4/4] Added support for keep alive websocket frames --- README.md | 1 + config.js | 6 +++++- graph/subscriptions.js | 8 +++++++- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 4ea9ff0e4..68547e7a8 100644 --- a/README.md +++ b/README.md @@ -50,6 +50,7 @@ sign and verify tokens via a `HS256` algorithm. - `TALK_RECAPTCHA_SECRET` (*required for reCAPTCHA support*) - server secret used for enabling reCAPTCHA powered logins. If not provided it will instead default to providing only a time based lockout. - `TALK_RECAPTCHA_PUBLIC` (*required for reCAPTCHA support*) - client secret used for enabling reCAPTCHA powered logins. If not provided it will instead default to providing only a time based lockout. - `TALK_PLUGINS_JSON` (_optional_) - used to specify the plugin config via the environment +- `TALK_KEEP_ALIVE` (_optional_) - The keepalive timeout that should be used to send keep alive messages through the websocket to keep the socket alive. (Default `30s`) Refer to the wiki page on [Configuration Loading](https://github.com/coralproject/talk/wiki/Configuration-Loading) for alternative methods of loading configuration during development. diff --git a/config.js b/config.js index 3d75f44a8..02f95d070 100644 --- a/config.js +++ b/config.js @@ -56,7 +56,11 @@ const CONFIG = { // The URL for this Talk Instance as viewable from the outside. ROOT_URL: process.env.TALK_ROOT_URL, - + + // The keepalive timeout (in ms) that should be used to send keep alive + // messages through the websocket to keep the socket alive. + KEEP_ALIVE: process.env.TALK_KEEP_ALIVE || '30s', + //------------------------------------------------------------------------------ // Recaptcha configuration //------------------------------------------------------------------------------ diff --git a/graph/subscriptions.js b/graph/subscriptions.js index 2ba0c2c1f..ec2d5b786 100644 --- a/graph/subscriptions.js +++ b/graph/subscriptions.js @@ -10,6 +10,11 @@ const plugins = require('../services/plugins'); const {deserializeUser} = require('../services/subscriptions'); +const ms = require('ms'); +const { + KEEP_ALIVE +} = require('../config'); + const { SUBSCRIBE_COMMENT_ACCEPTED, SUBSCRIBE_COMMENT_REJECTED, @@ -119,7 +124,8 @@ const createSubscriptionManager = (server) => new SubscriptionServer({ }; return baseParams; - } + }, + keepAlive: ms(KEEP_ALIVE) }, { server, path: '/api/v1/live'