From 4a2fbcaf983e3180e00bb846f4ed65a2670b9251 Mon Sep 17 00:00:00 2001 From: Joram Wilander Date: Thu, 18 Aug 2016 18:37:09 -0400 Subject: Add flagging functionality to search results (#3803) --- webapp/components/search_results_item.jsx | 57 +++++++++++++++++++------------ 1 file changed, 36 insertions(+), 21 deletions(-) (limited to 'webapp/components/search_results_item.jsx') diff --git a/webapp/components/search_results_item.jsx b/webapp/components/search_results_item.jsx index 65abc516e..ada5e0ea6 100644 --- a/webapp/components/search_results_item.jsx +++ b/webapp/components/search_results_item.jsx @@ -9,7 +9,7 @@ import UserStore from 'stores/user_store.jsx'; import AppDispatcher from '../dispatcher/app_dispatcher.jsx'; import * as GlobalActions from 'actions/global_actions.jsx'; -import {unflagPost, getFlaggedPosts} from 'actions/post_actions.jsx'; +import {flagPost, unflagPost} from 'actions/post_actions.jsx'; import * as TextFormatting from 'utils/text_formatting.jsx'; import * as Utils from 'utils/utils.jsx'; @@ -30,6 +30,7 @@ export default class SearchResultsItem extends React.Component { this.handleFocusRHSClick = this.handleFocusRHSClick.bind(this); this.shrinkSidebar = this.shrinkSidebar.bind(this); this.unflagPost = this.unflagPost.bind(this); + this.flagPost = this.flagPost.bind(this); } hideSidebar() { @@ -47,11 +48,14 @@ export default class SearchResultsItem extends React.Component { GlobalActions.emitPostFocusRightHandSideFromSearch(this.props.post, this.props.isMentionSearch); } + flagPost(e) { + e.preventDefault(); + flagPost(this.props.post.id); + } + unflagPost(e) { e.preventDefault(); - unflagPost(this.props.post.id, - () => getFlaggedPosts() - ); + unflagPost(this.props.post.id); } render() { @@ -110,6 +114,7 @@ export default class SearchResultsItem extends React.Component { } let flag; + let flagFunc; let flagVisible = ''; let flagTooltip = ( @@ -129,24 +134,21 @@ export default class SearchResultsItem extends React.Component { /> ); + flagFunc = this.unflagPost; flag = ( - - - - - + ); + } else { + flag = ( + + ); + flagFunc = this.flagPost; } return ( @@ -187,7 +189,19 @@ export default class SearchResultsItem extends React.Component { minute='2-digit' /> - {flag} + + + {flag} + +