[UI-AUTO] add IDs to last 10 posts' text (#6257)

Этот коммит содержится в:
Saturnino Abril
2017-05-09 21:53:59 +09:00
коммит произвёл Joram Wilander
родитель 2b18e782d6
Коммит 882172b298
6 изменённых файлов: 28 добавлений и 10 удалений

Просмотреть файл

@@ -22,7 +22,7 @@ export default class Post extends Component {
sameUser: PropTypes.bool, sameUser: PropTypes.bool,
sameRoot: PropTypes.bool, sameRoot: PropTypes.bool,
hideProfilePic: PropTypes.bool, hideProfilePic: PropTypes.bool,
isLastPost: PropTypes.bool, lastPostCount: PropTypes.number,
isLastComment: PropTypes.bool, isLastComment: PropTypes.bool,
shouldHighlight: PropTypes.bool, shouldHighlight: PropTypes.bool,
displayNameType: PropTypes.string, displayNameType: PropTypes.string,
@@ -137,6 +137,10 @@ export default class Post extends Component {
return true; return true;
} }
if (nextProps.lastPostCount !== this.props.lastPostCount) {
return true;
}
return false; return false;
} }
@@ -306,7 +310,7 @@ export default class Post extends Component {
post={post} post={post}
currentUser={this.props.currentUser} currentUser={this.props.currentUser}
sameRoot={this.props.sameRoot} sameRoot={this.props.sameRoot}
isLastPost={this.props.isLastPost} lastPostCount={this.props.lastPostCount}
parentPost={parentPost} parentPost={parentPost}
handleCommentClick={this.handleCommentClick} handleCommentClick={this.handleCommentClick}
compactDisplay={this.props.compactDisplay} compactDisplay={this.props.compactDisplay}

Просмотреть файл

@@ -51,6 +51,10 @@ export default class PostBody extends React.Component {
return true; return true;
} }
if (nextProps.lastPostCount !== this.props.lastPostCount) {
return true;
}
return false; return false;
} }
@@ -164,7 +168,7 @@ export default class PostBody extends React.Component {
> >
{loading} {loading}
<PostMessageContainer <PostMessageContainer
isLastPost={this.props.isLastPost} lastPostCount={this.props.lastPostCount}
post={this.props.post} post={this.props.post}
/> />
</div> </div>
@@ -208,7 +212,7 @@ PostBody.propTypes = {
currentUser: React.PropTypes.object.isRequired, currentUser: React.PropTypes.object.isRequired,
parentPost: React.PropTypes.object, parentPost: React.PropTypes.object,
retryPost: React.PropTypes.func, retryPost: React.PropTypes.func,
isLastPost: React.PropTypes.bool, lastPostCount: React.PropTypes.number,
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,

Просмотреть файл

@@ -339,7 +339,7 @@ export default class PostList extends React.Component {
<Post <Post
key={keyPrefix + 'postKey'} key={keyPrefix + 'postKey'}
ref={post.id} ref={post.id}
isLastPost={i === 0} lastPostCount={(i >= 0 && i < Constants.TEST_ID_COUNT) ? i : -1}
sameUser={sameUser} sameUser={sameUser}
sameRoot={sameRoot} sameRoot={sameRoot}
post={post} post={post}

Просмотреть файл

@@ -16,7 +16,7 @@ export default class PostMessageContainer extends React.Component {
static propTypes = { static propTypes = {
post: React.PropTypes.object.isRequired, post: React.PropTypes.object.isRequired,
options: React.PropTypes.object, options: React.PropTypes.object,
isLastPost: React.PropTypes.bool lastPostCount: React.PropTypes.number
}; };
static defaultProps = { static defaultProps = {
@@ -91,7 +91,7 @@ export default class PostMessageContainer extends React.Component {
<PostMessageView <PostMessageView
options={this.props.options} options={this.props.options}
post={this.props.post} post={this.props.post}
isLastPost={this.props.isLastPost} lastPostCount={this.props.lastPostCount}
emojis={this.state.emojis} emojis={this.state.emojis}
enableFormatting={this.state.enableFormatting} enableFormatting={this.state.enableFormatting}
mentionKeys={this.state.mentionKeys} mentionKeys={this.state.mentionKeys}

Просмотреть файл

@@ -22,7 +22,7 @@ export default class PostMessageView extends React.Component {
usernameMap: React.PropTypes.object.isRequired, usernameMap: React.PropTypes.object.isRequired,
channelNamesMap: React.PropTypes.object.isRequired, channelNamesMap: React.PropTypes.object.isRequired,
team: React.PropTypes.object.isRequired, team: React.PropTypes.object.isRequired,
isLastPost: React.PropTypes.bool lastPostCount: React.PropTypes.number
}; };
shouldComponentUpdate(nextProps) { shouldComponentUpdate(nextProps) {
@@ -55,6 +55,10 @@ export default class PostMessageView extends React.Component {
return true; return true;
} }
if (nextProps.lastPostCount !== this.props.lastPostCount) {
return true;
}
// Don't check if props.usernameMap changes since it is very large and inefficient to do so. // Don't check if props.usernameMap changes since it is very large and inefficient to do so.
// This mimics previous behaviour, but could be changed if we decide it's worth it. // This mimics previous behaviour, but could be changed if we decide it's worth it.
// The same choice (and reasoning) is also applied to the this.props.channelNamesMap. // The same choice (and reasoning) is also applied to the this.props.channelNamesMap.
@@ -111,10 +115,15 @@ export default class PostMessageView extends React.Component {
return <div>{renderedSystemMessage}</div>; return <div>{renderedSystemMessage}</div>;
} }
let postId = null;
if (this.props.lastPostCount >= 0) {
postId = Utils.createSafeId('lastPostMessageText' + this.props.lastPostCount);
}
return ( return (
<div> <div>
<span <span
id={this.props.isLastPost ? 'lastPostMessageText' : null} id={postId}
className='post-message__text' className='post-message__text'
onClick={Utils.handleFormattedTextClick} onClick={Utils.handleFormattedTextClick}
dangerouslySetInnerHTML={{__html: TextFormatting.formatText(this.props.post.message, options)}} dangerouslySetInnerHTML={{__html: TextFormatting.formatText(this.props.post.message, options)}}

Просмотреть файл

@@ -952,7 +952,8 @@ export const Constants = {
AUTOCOMPLETE_TIMEOUT: 100, AUTOCOMPLETE_TIMEOUT: 100,
ANIMATION_TIMEOUT: 1000, ANIMATION_TIMEOUT: 1000,
SEARCH_TIMEOUT_MILLISECONDS: 100, SEARCH_TIMEOUT_MILLISECONDS: 100,
DIAGNOSTICS_SEGMENT_KEY: 'fwb7VPbFeQ7SKp3wHm1RzFUuXZudqVok' DIAGNOSTICS_SEGMENT_KEY: 'fwb7VPbFeQ7SKp3wHm1RzFUuXZudqVok',
TEST_ID_COUNT: 10
}; };
export default Constants; export default Constants;