Highlight comment bar for comments considered mentions (#3938)
Этот коммит содержится в:
коммит произвёл
Corey Hulen
родитель
2031873cb1
Коммит
05af5d14b8
@@ -236,7 +236,6 @@ export default class Post extends React.Component {
|
|||||||
post={post}
|
post={post}
|
||||||
sameRoot={this.props.sameRoot}
|
sameRoot={this.props.sameRoot}
|
||||||
commentCount={commentCount}
|
commentCount={commentCount}
|
||||||
isCommentMention={this.props.isCommentMention}
|
|
||||||
handleCommentClick={this.handleCommentClick}
|
handleCommentClick={this.handleCommentClick}
|
||||||
handleDropdownOpened={this.handleDropdownOpened}
|
handleDropdownOpened={this.handleDropdownOpened}
|
||||||
isLastComment={this.props.isLastComment}
|
isLastComment={this.props.isLastComment}
|
||||||
@@ -255,6 +254,7 @@ export default class Post extends React.Component {
|
|||||||
handleCommentClick={this.handleCommentClick}
|
handleCommentClick={this.handleCommentClick}
|
||||||
compactDisplay={this.props.compactDisplay}
|
compactDisplay={this.props.compactDisplay}
|
||||||
previewCollapsed={this.props.previewCollapsed}
|
previewCollapsed={this.props.previewCollapsed}
|
||||||
|
isCommentMention={this.props.isCommentMention}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -23,6 +23,10 @@ export default class PostBody extends React.Component {
|
|||||||
this.removePost = this.removePost.bind(this);
|
this.removePost = this.removePost.bind(this);
|
||||||
}
|
}
|
||||||
shouldComponentUpdate(nextProps) {
|
shouldComponentUpdate(nextProps) {
|
||||||
|
if (nextProps.isCommentMention !== this.props.isCommentMention) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
if (!Utils.areObjectsEqual(nextProps.post, this.props.post)) {
|
if (!Utils.areObjectsEqual(nextProps.post, this.props.post)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -190,10 +194,15 @@ export default class PostBody extends React.Component {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let mentionHighlightClass = '';
|
||||||
|
if (this.props.isCommentMention) {
|
||||||
|
mentionHighlightClass = 'mention-comment';
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
{comment}
|
{comment}
|
||||||
<div className='post__body'>
|
<div className={'post__body ' + mentionHighlightClass}>
|
||||||
{messageWithAdditionalContent}
|
{messageWithAdditionalContent}
|
||||||
{fileAttachmentHolder}
|
{fileAttachmentHolder}
|
||||||
</div>
|
</div>
|
||||||
@@ -208,5 +217,6 @@ PostBody.propTypes = {
|
|||||||
retryPost: React.PropTypes.func.isRequired,
|
retryPost: React.PropTypes.func.isRequired,
|
||||||
handleCommentClick: React.PropTypes.func.isRequired,
|
handleCommentClick: React.PropTypes.func.isRequired,
|
||||||
compactDisplay: React.PropTypes.bool,
|
compactDisplay: React.PropTypes.bool,
|
||||||
previewCollapsed: React.PropTypes.string
|
previewCollapsed: React.PropTypes.string,
|
||||||
|
isCommentMention: React.PropTypes.bool
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -64,7 +64,6 @@ export default class PostHeader extends React.Component {
|
|||||||
<PostInfo
|
<PostInfo
|
||||||
post={post}
|
post={post}
|
||||||
commentCount={this.props.commentCount}
|
commentCount={this.props.commentCount}
|
||||||
isCommentMention={this.props.isCommentMention}
|
|
||||||
handleCommentClick={this.props.handleCommentClick}
|
handleCommentClick={this.props.handleCommentClick}
|
||||||
handleDropdownOpened={this.props.handleDropdownOpened}
|
handleDropdownOpened={this.props.handleDropdownOpened}
|
||||||
allowReply={!isSystemMessage}
|
allowReply={!isSystemMessage}
|
||||||
@@ -92,7 +91,6 @@ PostHeader.propTypes = {
|
|||||||
user: React.PropTypes.object,
|
user: React.PropTypes.object,
|
||||||
currentUser: React.PropTypes.object.isRequired,
|
currentUser: React.PropTypes.object.isRequired,
|
||||||
commentCount: React.PropTypes.number.isRequired,
|
commentCount: React.PropTypes.number.isRequired,
|
||||||
isCommentMention: React.PropTypes.bool.isRequired,
|
|
||||||
isLastComment: React.PropTypes.bool.isRequired,
|
isLastComment: React.PropTypes.bool.isRequired,
|
||||||
handleCommentClick: React.PropTypes.func.isRequired,
|
handleCommentClick: React.PropTypes.func.isRequired,
|
||||||
handleDropdownOpened: React.PropTypes.func.isRequired,
|
handleDropdownOpened: React.PropTypes.func.isRequired,
|
||||||
|
|||||||
@@ -250,7 +250,6 @@ export default class PostInfo extends React.Component {
|
|||||||
var post = this.props.post;
|
var post = this.props.post;
|
||||||
var comments = '';
|
var comments = '';
|
||||||
var showCommentClass = '';
|
var showCommentClass = '';
|
||||||
var highlightMentionClass = '';
|
|
||||||
var commentCountText = this.props.commentCount;
|
var commentCountText = this.props.commentCount;
|
||||||
const flagIcon = Constants.FLAG_ICON_SVG;
|
const flagIcon = Constants.FLAG_ICON_SVG;
|
||||||
|
|
||||||
@@ -260,15 +259,11 @@ export default class PostInfo extends React.Component {
|
|||||||
commentCountText = '';
|
commentCountText = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.props.isCommentMention) {
|
|
||||||
highlightMentionClass = ' mention--highlight';
|
|
||||||
}
|
|
||||||
|
|
||||||
if (post.state !== Constants.POST_FAILED && post.state !== Constants.POST_LOADING && !Utils.isPostEphemeral(post) && this.props.allowReply) {
|
if (post.state !== Constants.POST_FAILED && post.state !== Constants.POST_LOADING && !Utils.isPostEphemeral(post) && this.props.allowReply) {
|
||||||
comments = (
|
comments = (
|
||||||
<a
|
<a
|
||||||
href='#'
|
href='#'
|
||||||
className={'comment-icon__container' + showCommentClass + highlightMentionClass}
|
className={'comment-icon__container' + showCommentClass}
|
||||||
onClick={this.props.handleCommentClick}
|
onClick={this.props.handleCommentClick}
|
||||||
>
|
>
|
||||||
<span
|
<span
|
||||||
@@ -386,7 +381,6 @@ PostInfo.defaultProps = {
|
|||||||
PostInfo.propTypes = {
|
PostInfo.propTypes = {
|
||||||
post: React.PropTypes.object.isRequired,
|
post: React.PropTypes.object.isRequired,
|
||||||
commentCount: React.PropTypes.number.isRequired,
|
commentCount: React.PropTypes.number.isRequired,
|
||||||
isCommentMention: React.PropTypes.bool.isRequired,
|
|
||||||
isLastComment: React.PropTypes.bool.isRequired,
|
isLastComment: React.PropTypes.bool.isRequired,
|
||||||
allowReply: React.PropTypes.bool.isRequired,
|
allowReply: React.PropTypes.bool.isRequired,
|
||||||
handleCommentClick: React.PropTypes.func.isRequired,
|
handleCommentClick: React.PropTypes.func.isRequired,
|
||||||
|
|||||||
@@ -253,35 +253,34 @@ export default class PostList extends React.Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let commentCount = 0;
|
let commentCount = 0;
|
||||||
let nonOwnCommentsExists = false;
|
|
||||||
let isCommentMention = false;
|
let isCommentMention = false;
|
||||||
|
let lastCommentOnThreadTime = Number.MAX_SAFE_INTEGER;
|
||||||
let commentRootId;
|
let commentRootId;
|
||||||
if (parentPost) {
|
if (parentPost) {
|
||||||
commentRootId = post.root_id;
|
commentRootId = post.root_id;
|
||||||
} else {
|
} else {
|
||||||
commentRootId = post.id;
|
commentRootId = post.id;
|
||||||
}
|
}
|
||||||
if (commentRootId) {
|
|
||||||
const commentsNotifyLevel = this.props.currentUser.notify_props.comments || 'never';
|
for (const postId in posts) {
|
||||||
for (const postId in posts) {
|
if (posts[postId].root_id === commentRootId) {
|
||||||
if (posts[postId].root_id === commentRootId) {
|
commentCount += 1;
|
||||||
commentCount += 1;
|
if (posts[postId].user_id === userId && (lastCommentOnThreadTime === Number.MAX_SAFE_INTEGER || lastCommentOnThreadTime < posts[postId].create_at)) {
|
||||||
if (posts[postId].user_id !== this.props.currentUser.id) {
|
lastCommentOnThreadTime = posts[postId].create_at;
|
||||||
nonOwnCommentsExists = true;
|
|
||||||
}
|
|
||||||
if (posts[postId].user_id === this.props.currentUser.id && commentsNotifyLevel === 'any' && !isCommentMention) {
|
|
||||||
for (const nextPostId in posts) {
|
|
||||||
if (posts[nextPostId].root_id === commentRootId && posts[nextPostId].user_id !== this.props.currentUser.id &&
|
|
||||||
posts[postId].create_at < posts[nextPostId].create_at) {
|
|
||||||
isCommentMention = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (nonOwnCommentsExists && posts[commentRootId].user_id === this.props.currentUser.id && commentsNotifyLevel !== 'never') {
|
}
|
||||||
isCommentMention = true;
|
|
||||||
|
if (parentPost && commentRootId) {
|
||||||
|
const commentsNotifyLevel = this.props.currentUser.notify_props.comments || 'never';
|
||||||
|
const notCurrentUser = post.user_id !== userId || (post.props && post.props.from_webhook);
|
||||||
|
const notViewed = this.props.lastViewed !== 0 && post.create_at > this.props.lastViewed;
|
||||||
|
if (notCurrentUser && notViewed) {
|
||||||
|
if (commentsNotifyLevel === 'any' && (posts[commentRootId].user_id === userId || post.create_at > lastCommentOnThreadTime)) {
|
||||||
|
isCommentMention = true;
|
||||||
|
} else if (commentsNotifyLevel === 'root' && posts[commentRootId].user_id === userId) {
|
||||||
|
isCommentMention = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -681,6 +681,11 @@ body.ios {
|
|||||||
.post__body {
|
.post__body {
|
||||||
border-left: 4px solid $gray;
|
border-left: 4px solid $gray;
|
||||||
padding-left: 7px;
|
padding-left: 7px;
|
||||||
|
|
||||||
|
&.mention-comment {
|
||||||
|
border-left: 4px solid $yellow;
|
||||||
|
border-color: $yellow;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -663,9 +663,7 @@ export function applyTheme(theme) {
|
|||||||
|
|
||||||
if (theme.mentionHighlightBg) {
|
if (theme.mentionHighlightBg) {
|
||||||
changeCss('.app__body .mention--highlight, .app__body .search-highlight', 'background:' + theme.mentionHighlightBg, 1);
|
changeCss('.app__body .mention--highlight, .app__body .search-highlight', 'background:' + theme.mentionHighlightBg, 1);
|
||||||
}
|
changeCss('.mention-comment', 'border-color:' + theme.mentionHighlightBg + ' !important', 1);
|
||||||
|
|
||||||
if (theme.mentionHighlightBg) {
|
|
||||||
changeCss('.app__body .post.post--highlight', 'background:' + changeOpacity(theme.mentionHighlightBg, 0.5), 1);
|
changeCss('.app__body .post.post--highlight', 'background:' + changeOpacity(theme.mentionHighlightBg, 0.5), 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user