Deleted posts now update in search results and flagged posts (#4618)
Этот коммит содержится в:
коммит произвёл
Harrison Healey
родитель
48d64f3f68
Коммит
3c65a20f45
@@ -19,7 +19,7 @@ import React from 'react';
|
|||||||
import {FormattedMessage, FormattedHTMLMessage} from 'react-intl';
|
import {FormattedMessage, FormattedHTMLMessage} from 'react-intl';
|
||||||
|
|
||||||
function getStateFromStores() {
|
function getStateFromStores() {
|
||||||
const results = SearchStore.getSearchResults();
|
const results = JSON.parse(JSON.stringify(SearchStore.getSearchResults()));
|
||||||
|
|
||||||
const channels = new Map();
|
const channels = new Map();
|
||||||
|
|
||||||
|
|||||||
@@ -111,6 +111,19 @@ export default class SearchResultsItem extends React.Component {
|
|||||||
compactClass = 'post--compact';
|
compactClass = 'post--compact';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let message;
|
||||||
|
let flagContent;
|
||||||
|
let rhsControls;
|
||||||
|
if (post.state === Constants.POST_DELETED) {
|
||||||
|
message = (
|
||||||
|
<p>
|
||||||
|
<FormattedMessage
|
||||||
|
id='post_body.deleted'
|
||||||
|
defaultMessage='(message deleted)'
|
||||||
|
/>
|
||||||
|
</p>
|
||||||
|
);
|
||||||
|
} else {
|
||||||
let flag;
|
let flag;
|
||||||
let flagFunc;
|
let flagFunc;
|
||||||
let flagVisible = '';
|
let flagVisible = '';
|
||||||
@@ -122,6 +135,7 @@ export default class SearchResultsItem extends React.Component {
|
|||||||
/>
|
/>
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
);
|
);
|
||||||
|
|
||||||
if (this.props.isFlagged) {
|
if (this.props.isFlagged) {
|
||||||
flagVisible = 'visible';
|
flagVisible = 'visible';
|
||||||
flagTooltip = (
|
flagTooltip = (
|
||||||
@@ -149,44 +163,7 @@ export default class SearchResultsItem extends React.Component {
|
|||||||
flagFunc = this.flagPost;
|
flagFunc = this.flagPost;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
flagContent = (
|
||||||
<div className='search-item__container'>
|
|
||||||
<div className='date-separator'>
|
|
||||||
<hr className='separator__hr'/>
|
|
||||||
<div className='separator__text'>
|
|
||||||
<FormattedDate
|
|
||||||
value={post.create_at}
|
|
||||||
day='numeric'
|
|
||||||
month='long'
|
|
||||||
year='numeric'
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div
|
|
||||||
className={'post post--thread ' + compactClass}
|
|
||||||
>
|
|
||||||
<div className='search-channel__name'>{channelName}</div>
|
|
||||||
<div className='post__content'>
|
|
||||||
{profilePicContainer}
|
|
||||||
<div>
|
|
||||||
<ul className='post__header'>
|
|
||||||
<li className='col col__name'><strong>
|
|
||||||
<UserProfile
|
|
||||||
user={user}
|
|
||||||
overwriteName={overrideUsername}
|
|
||||||
disablePopover={disableProfilePopover}
|
|
||||||
/>
|
|
||||||
</strong></li>
|
|
||||||
{botIndicator}
|
|
||||||
<li className='col'>
|
|
||||||
<time className='search-item-time'>
|
|
||||||
<FormattedDate
|
|
||||||
value={post.create_at}
|
|
||||||
hour12={!this.props.useMilitaryTime}
|
|
||||||
hour='2-digit'
|
|
||||||
minute='2-digit'
|
|
||||||
/>
|
|
||||||
</time>
|
|
||||||
<OverlayTrigger
|
<OverlayTrigger
|
||||||
delayShow={Constants.OVERLAY_TIME_DELAY}
|
delayShow={Constants.OVERLAY_TIME_DELAY}
|
||||||
placement='top'
|
placement='top'
|
||||||
@@ -200,7 +177,9 @@ export default class SearchResultsItem extends React.Component {
|
|||||||
{flag}
|
{flag}
|
||||||
</a>
|
</a>
|
||||||
</OverlayTrigger>
|
</OverlayTrigger>
|
||||||
</li>
|
);
|
||||||
|
|
||||||
|
rhsControls = (
|
||||||
<li className='col__controls'>
|
<li className='col__controls'>
|
||||||
<a
|
<a
|
||||||
href='#'
|
href='#'
|
||||||
@@ -247,8 +226,9 @@ export default class SearchResultsItem extends React.Component {
|
|||||||
/>
|
/>
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
);
|
||||||
<div className='search-item-snippet'>
|
|
||||||
|
message = (
|
||||||
<PostMessageContainer
|
<PostMessageContainer
|
||||||
post={post}
|
post={post}
|
||||||
options={{
|
options={{
|
||||||
@@ -256,6 +236,53 @@ export default class SearchResultsItem extends React.Component {
|
|||||||
mentionHighlight: this.props.isMentionSearch
|
mentionHighlight: this.props.isMentionSearch
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className='search-item__container'>
|
||||||
|
<div className='date-separator'>
|
||||||
|
<hr className='separator__hr'/>
|
||||||
|
<div className='separator__text'>
|
||||||
|
<FormattedDate
|
||||||
|
value={post.create_at}
|
||||||
|
day='numeric'
|
||||||
|
month='long'
|
||||||
|
year='numeric'
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div
|
||||||
|
className={'post post--thread ' + compactClass}
|
||||||
|
>
|
||||||
|
<div className='search-channel__name'>{channelName}</div>
|
||||||
|
<div className='post__content'>
|
||||||
|
{profilePicContainer}
|
||||||
|
<div>
|
||||||
|
<ul className='post__header'>
|
||||||
|
<li className='col col__name'><strong>
|
||||||
|
<UserProfile
|
||||||
|
user={user}
|
||||||
|
overwriteName={overrideUsername}
|
||||||
|
disablePopover={disableProfilePopover}
|
||||||
|
/>
|
||||||
|
</strong></li>
|
||||||
|
{botIndicator}
|
||||||
|
<li className='col'>
|
||||||
|
<time className='search-item-time'>
|
||||||
|
<FormattedDate
|
||||||
|
value={post.create_at}
|
||||||
|
hour12={!this.props.useMilitaryTime}
|
||||||
|
hour='2-digit'
|
||||||
|
minute='2-digit'
|
||||||
|
/>
|
||||||
|
</time>
|
||||||
|
{flagContent}
|
||||||
|
</li>
|
||||||
|
{rhsControls}
|
||||||
|
</ul>
|
||||||
|
<div className='search-item-snippet'>
|
||||||
|
{message}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -39,7 +39,8 @@ export default class SuggestionBox extends React.Component {
|
|||||||
componentWillReceiveProps(nextProps) {
|
componentWillReceiveProps(nextProps) {
|
||||||
// Clear any suggestions when the SuggestionBox is cleared
|
// Clear any suggestions when the SuggestionBox is cleared
|
||||||
if (nextProps.value === '' && this.props.value !== nextProps.value) {
|
if (nextProps.value === '' && this.props.value !== nextProps.value) {
|
||||||
GlobalActions.emitClearSuggestions(this.suggestionId);
|
// TODO - Find a better way to not "dispatch during dispatch"
|
||||||
|
setTimeout(() => GlobalActions.emitClearSuggestions(this.suggestionId), 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -96,6 +96,21 @@ class SearchStoreClass extends EventEmitter {
|
|||||||
this.isMentionSearch = isMentionSearch;
|
this.isMentionSearch = isMentionSearch;
|
||||||
this.isFlaggedPosts = isFlaggedPosts;
|
this.isFlaggedPosts = isFlaggedPosts;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
deletePost(post) {
|
||||||
|
const results = this.getSearchResults();
|
||||||
|
if (results == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (post.id in results.posts) {
|
||||||
|
// make sure to copy the post so that component state changes work properly
|
||||||
|
results.posts[post.id] = Object.assign({}, post, {
|
||||||
|
state: Constants.POST_DELETED,
|
||||||
|
file_ids: []
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var SearchStore = new SearchStoreClass();
|
var SearchStore = new SearchStoreClass();
|
||||||
@@ -115,6 +130,10 @@ SearchStore.dispatchToken = AppDispatcher.register((payload) => {
|
|||||||
case ActionTypes.SHOW_SEARCH:
|
case ActionTypes.SHOW_SEARCH:
|
||||||
SearchStore.emitShowSearch();
|
SearchStore.emitShowSearch();
|
||||||
break;
|
break;
|
||||||
|
case ActionTypes.POST_DELETED:
|
||||||
|
SearchStore.deletePost(action.post);
|
||||||
|
SearchStore.emitSearchChange();
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user