Fix badge render (#1134)
This commit is contained in:
parent
4896716668
commit
2792e3bab1
2 changed files with 17 additions and 25 deletions
|
|
@ -32,7 +32,6 @@ export default class Badge extends PureComponent {
|
|||
constructor(props) {
|
||||
super(props);
|
||||
|
||||
this.width = 0;
|
||||
this.mounted = false;
|
||||
}
|
||||
|
||||
|
|
@ -67,6 +66,8 @@ export default class Badge extends PureComponent {
|
|||
};
|
||||
|
||||
onLayout = (e) => {
|
||||
const height = Math.max(e.nativeEvent.layout.height, this.props.minHeight);
|
||||
const borderRadius = height / 2;
|
||||
let width;
|
||||
|
||||
if (e.nativeEvent.layout.width <= e.nativeEvent.layout.height) {
|
||||
|
|
@ -75,26 +76,14 @@ export default class Badge extends PureComponent {
|
|||
width = e.nativeEvent.layout.width + this.props.extraPaddingHorizontal;
|
||||
}
|
||||
width = Math.max(width, this.props.minWidth);
|
||||
if (this.width === width) {
|
||||
return;
|
||||
}
|
||||
this.width = width;
|
||||
const height = Math.max(e.nativeEvent.layout.height, this.props.minHeight);
|
||||
const borderRadius = height / 2;
|
||||
this.setNativeProps({
|
||||
style: {
|
||||
width,
|
||||
height,
|
||||
borderRadius
|
||||
borderRadius,
|
||||
opacity: 1
|
||||
}
|
||||
});
|
||||
setTimeout(() => {
|
||||
this.setNativeProps({
|
||||
style: {
|
||||
opacity: 1
|
||||
}
|
||||
});
|
||||
}, 100);
|
||||
};
|
||||
|
||||
renderText = () => {
|
||||
|
|
|
|||
|
|
@ -11,18 +11,21 @@ import {removeProtocol} from 'app/utils/url';
|
|||
|
||||
import TeamsListItem from './teams_list_item.js';
|
||||
|
||||
function mapStateToProps(state, ownProps) {
|
||||
const team = getTeam(state, ownProps.teamId);
|
||||
function makeMapStateToProps() {
|
||||
const getMentionCount = makeGetBadgeCountForTeamId();
|
||||
|
||||
return {
|
||||
currentTeamId: getCurrentTeamId(state),
|
||||
currentUrl: removeProtocol(getCurrentUrl(state)),
|
||||
displayName: team.display_name,
|
||||
mentionCount: getMentionCount(state, ownProps.teamId),
|
||||
name: team.name,
|
||||
theme: getTheme(state)
|
||||
return function mapStateToProps(state, ownProps) {
|
||||
const team = getTeam(state, ownProps.teamId);
|
||||
|
||||
return {
|
||||
currentTeamId: getCurrentTeamId(state),
|
||||
currentUrl: removeProtocol(getCurrentUrl(state)),
|
||||
displayName: team.display_name,
|
||||
mentionCount: getMentionCount(state, ownProps.teamId),
|
||||
name: team.name,
|
||||
theme: getTheme(state)
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
export default connect(mapStateToProps)(TeamsListItem);
|
||||
export default connect(makeMapStateToProps)(TeamsListItem);
|
||||
|
|
|
|||
Loading…
Reference in a new issue