Move post_body profile change listener into posts view
Этот коммит содержится в:
@@ -147,8 +147,8 @@ export default class ChannelHeader extends React.Component {
|
|||||||
</Popover>
|
</Popover>
|
||||||
);
|
);
|
||||||
let channelTitle = channel.display_name;
|
let channelTitle = channel.display_name;
|
||||||
const currentId = this.prop.user.id;
|
const currentId = this.props.user.id;
|
||||||
const isAdmin = Utils.isAdmin(this.state.memberChannel.roles) || Utils.isAdmin(this.state.memberTeam.roles);
|
const isAdmin = Utils.isAdmin(this.state.memberChannel.roles) || Utils.isAdmin(this.props.user.roles);
|
||||||
const isDirect = (this.state.channel.type === 'D');
|
const isDirect = (this.state.channel.type === 'D');
|
||||||
|
|
||||||
if (isDirect) {
|
if (isDirect) {
|
||||||
|
|||||||
@@ -99,6 +99,10 @@ export default class Post extends React.Component {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (nextProps.hasProfiles !== this.props.hasProfiles) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
getCommentCount(props) {
|
getCommentCount(props) {
|
||||||
@@ -223,6 +227,7 @@ export default class Post extends React.Component {
|
|||||||
posts={posts}
|
posts={posts}
|
||||||
handleCommentClick={this.handleCommentClick}
|
handleCommentClick={this.handleCommentClick}
|
||||||
retryPost={this.retryPost}
|
retryPost={this.retryPost}
|
||||||
|
hasProfiles={this.props.hasProfiles}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -233,7 +238,7 @@ export default class Post extends React.Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Post.propTypes = {
|
Post.propTypes = {
|
||||||
post: React.PropTypes.object,
|
post: React.PropTypes.object.isRequired,
|
||||||
posts: React.PropTypes.object,
|
posts: React.PropTypes.object,
|
||||||
parentPost: React.PropTypes.object,
|
parentPost: React.PropTypes.object,
|
||||||
sameUser: React.PropTypes.bool,
|
sameUser: React.PropTypes.bool,
|
||||||
@@ -241,5 +246,6 @@ Post.propTypes = {
|
|||||||
hideProfilePic: React.PropTypes.bool,
|
hideProfilePic: React.PropTypes.bool,
|
||||||
isLastComment: React.PropTypes.bool,
|
isLastComment: React.PropTypes.bool,
|
||||||
shouldHighlight: React.PropTypes.bool,
|
shouldHighlight: React.PropTypes.bool,
|
||||||
displayNameType: React.PropTypes.string
|
displayNameType: React.PropTypes.string,
|
||||||
|
hasProfiles: React.PropTypes.bool
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -33,7 +33,6 @@ class PostBody extends React.Component {
|
|||||||
|
|
||||||
this.isImgLoading = false;
|
this.isImgLoading = false;
|
||||||
|
|
||||||
this.handleUserChange = this.handleUserChange.bind(this);
|
|
||||||
this.parseEmojis = this.parseEmojis.bind(this);
|
this.parseEmojis = this.parseEmojis.bind(this);
|
||||||
this.createEmbed = this.createEmbed.bind(this);
|
this.createEmbed = this.createEmbed.bind(this);
|
||||||
this.createImageEmbed = this.createImageEmbed.bind(this);
|
this.createImageEmbed = this.createImageEmbed.bind(this);
|
||||||
@@ -80,26 +79,12 @@ class PostBody extends React.Component {
|
|||||||
|
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
this.parseEmojis();
|
this.parseEmojis();
|
||||||
|
|
||||||
UserStore.addChangeListener(this.handleUserChange);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
componentDidUpdate() {
|
componentDidUpdate() {
|
||||||
this.parseEmojis();
|
this.parseEmojis();
|
||||||
}
|
}
|
||||||
|
|
||||||
componentWillUnmount() {
|
|
||||||
UserStore.removeChangeListener(this.handleUserChange);
|
|
||||||
}
|
|
||||||
|
|
||||||
handleUserChange() {
|
|
||||||
if (!this.state.hasProfiles) {
|
|
||||||
const profiles = UserStore.getProfiles();
|
|
||||||
|
|
||||||
this.setState({hasProfiles: profiles && Object.keys(profiles).length > 1});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
componentWillReceiveProps(nextProps) {
|
componentWillReceiveProps(nextProps) {
|
||||||
const linkData = Utils.extractLinks(nextProps.post.message);
|
const linkData = Utils.extractLinks(nextProps.post.message);
|
||||||
if (this.props.post.filenames.length === 0 && this.state.links && this.state.links.length > 0) {
|
if (this.props.post.filenames.length === 0 && this.state.links && this.state.links.length > 0) {
|
||||||
@@ -357,7 +342,8 @@ PostBody.propTypes = {
|
|||||||
post: React.PropTypes.object.isRequired,
|
post: React.PropTypes.object.isRequired,
|
||||||
parentPost: React.PropTypes.object,
|
parentPost: React.PropTypes.object,
|
||||||
retryPost: React.PropTypes.func.isRequired,
|
retryPost: React.PropTypes.func.isRequired,
|
||||||
handleCommentClick: React.PropTypes.func.isRequired
|
handleCommentClick: React.PropTypes.func.isRequired,
|
||||||
|
hasProfiles: React.PropTypes.bool
|
||||||
};
|
};
|
||||||
|
|
||||||
export default injectIntl(PostBody);
|
export default injectIntl(PostBody);
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ export default class PostsView extends React.Component {
|
|||||||
this.handleResize = this.handleResize.bind(this);
|
this.handleResize = this.handleResize.bind(this);
|
||||||
this.scrollToBottom = this.scrollToBottom.bind(this);
|
this.scrollToBottom = this.scrollToBottom.bind(this);
|
||||||
this.scrollToBottomAnimated = this.scrollToBottomAnimated.bind(this);
|
this.scrollToBottomAnimated = this.scrollToBottomAnimated.bind(this);
|
||||||
|
this.onUserChange = this.onUserChange.bind(this);
|
||||||
|
|
||||||
this.jumpToPostNode = null;
|
this.jumpToPostNode = null;
|
||||||
this.wasAtBottom = true;
|
this.wasAtBottom = true;
|
||||||
@@ -38,7 +39,8 @@ export default class PostsView extends React.Component {
|
|||||||
this.state = {
|
this.state = {
|
||||||
displayNameType: PreferenceStore.get(Preferences.CATEGORY_DISPLAY_SETTINGS, 'name_format', 'false'),
|
displayNameType: PreferenceStore.get(Preferences.CATEGORY_DISPLAY_SETTINGS, 'name_format', 'false'),
|
||||||
isScrolling: false,
|
isScrolling: false,
|
||||||
topPostId: null
|
topPostId: null,
|
||||||
|
hasProfiles: false
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
static get SCROLL_TYPE_FREE() {
|
static get SCROLL_TYPE_FREE() {
|
||||||
@@ -242,6 +244,7 @@ export default class PostsView extends React.Component {
|
|||||||
shouldHighlight={shouldHighlight}
|
shouldHighlight={shouldHighlight}
|
||||||
onClick={() => EventHelpers.emitPostFocusEvent(post.id)} //eslint-disable-line no-loop-func
|
onClick={() => EventHelpers.emitPostFocusEvent(post.id)} //eslint-disable-line no-loop-func
|
||||||
displayNameType={this.state.displayNameType}
|
displayNameType={this.state.displayNameType}
|
||||||
|
hasProfiles={this.state.hasProfiles}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -367,9 +370,11 @@ export default class PostsView extends React.Component {
|
|||||||
if (this.props.postList != null) {
|
if (this.props.postList != null) {
|
||||||
this.updateScrolling();
|
this.updateScrolling();
|
||||||
}
|
}
|
||||||
|
UserStore.addChangeListener(this.onUserChange);
|
||||||
window.addEventListener('resize', this.handleResize);
|
window.addEventListener('resize', this.handleResize);
|
||||||
}
|
}
|
||||||
componentWillUnmount() {
|
componentWillUnmount() {
|
||||||
|
UserStore.removeChangeListener(this.onUserChange);
|
||||||
window.removeEventListener('resize', this.handleResize);
|
window.removeEventListener('resize', this.handleResize);
|
||||||
}
|
}
|
||||||
componentDidUpdate() {
|
componentDidUpdate() {
|
||||||
@@ -413,9 +418,19 @@ export default class PostsView extends React.Component {
|
|||||||
if (this.state.isScrolling !== nextState.isScrolling) {
|
if (this.state.isScrolling !== nextState.isScrolling) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
if (this.state.hasProfiles !== nextState.hasProfiles) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
onUserChange() {
|
||||||
|
if (!this.state.hasProfiles) {
|
||||||
|
const profiles = UserStore.getProfiles();
|
||||||
|
|
||||||
|
this.setState({hasProfiles: profiles && Object.keys(profiles).length > 1});
|
||||||
|
}
|
||||||
|
}
|
||||||
render() {
|
render() {
|
||||||
let posts = [];
|
let posts = [];
|
||||||
let order = [];
|
let order = [];
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user