Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix-extra spacing shown when avatar is not rendered #447

Merged
merged 2 commits into from
May 14, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ See [example/App.js](example/App.js)
- **`isLoadingEarlier`** _(Bool)_ - display an ActivityIndicator when loading earlier messages
- **`renderLoading`** _(Function)_ - render a loading view when initializing
- **`renderLoadEarlier`** _(Function)_ - render the load earlier button
- **`renderAvatar`** _(Function)_ - renders the message avatar
- **`renderAvatar`** _(Function)_ - renders the message avatar. Set to `null` to not render any avatar for the message
- **`onPressAvatar`** _(Function(`user`))_ - callback when a message avatar is tapped
- **`renderAvatarOnTop`** _(Bool)_ - render the message avatar, on top of consecutive messages. The default value is `false`.
- **`renderBubble`** _(Function)_ - render the message bubble
Expand Down
5 changes: 5 additions & 0 deletions src/Avatar.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ export default class Avatar extends React.Component {
const messageToCompare = renderAvatarOnTop ? this.props.previousMessage : this.props.nextMessage;
const computedStyle = renderAvatarOnTop ? "onTop" : "onBottom"

if (this.props.renderAvatar === null) {
return null
}

if (isSameUser(this.props.currentMessage, messageToCompare) && isSameDay(this.props.currentMessage, messageToCompare)) {
return (
<View style={[styles[this.props.position].container, this.props.containerStyle[this.props.position]]}>
Expand All @@ -32,6 +36,7 @@ export default class Avatar extends React.Component {
</View>
);
}

return (
<View
style={[styles[this.props.position].container, styles[this.props.position][computedStyle], this.props.containerStyle[this.props.position]]}>
Expand Down