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

Bot message implementation (quick replies copy and inspiration) #1211

Merged
merged 17 commits into from
May 21, 2019
Prev Previous commit
Next Next commit
fix show avatar
  • Loading branch information
xcarpentier committed May 20, 2019
commit e0aa57f1dda769fa25f7fa12eaca281d341456b2
2 changes: 1 addition & 1 deletion App.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { AppLoading, Asset, Linking } from 'expo'
import React, { Component } from 'react'
import { StyleSheet, View } from 'react-native'
import { StyleSheet, View, Text } from 'react-native'
import { Bubble, GiftedChat, SystemMessage } from './src/'

import AccessoryBar from './example-expo/AccessoryBar'
Expand Down
22 changes: 18 additions & 4 deletions src/Message.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ interface MessageProps<TMessage extends IMessage = IMessage> {
currentMessage?: TMessage
nextMessage?: TMessage
previousMessage?: TMessage
user?: User
user: User
inverted?: boolean
containerStyle?: LeftRightStyle<ViewStyle>
renderBubble?(props: Bubble['props']): React.ReactNode
Expand All @@ -59,7 +59,7 @@ export default class Message extends React.Component<MessageProps> {
previousMessage: {},
user: {},
containerStyle: {},
showUserAvatar: true,
showUserAvatar: false,
inverted: true,
}

Expand Down Expand Up @@ -128,19 +128,33 @@ export default class Message extends React.Component<MessageProps> {
}

renderAvatar() {
const { user, currentMessage } = this.props
const { user, currentMessage, showUserAvatar } = this.props
console.warn({
cond:
user &&
user._id &&
currentMessage &&
user._id === currentMessage.user._id &&
!showUserAvatar,
showUserAvatar,
user,
currentMessage,
})

if (
user &&
user._id &&
currentMessage &&
user._id === currentMessage.user._id &&
!this.props.showUserAvatar
!showUserAvatar
) {
return null
}

if (currentMessage && currentMessage.user.avatar === null) {
return null
}

const { containerStyle, ...props } = this.props
return <Avatar {...props} />
}
Expand Down
1 change: 1 addition & 0 deletions src/MessageContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,7 @@ export default class MessageContainer extends React.PureComponent<

const messageProps: Message['props'] = {
...restProps,
user,
key: item._id,
currentMessage: item,
previousMessage,
Expand Down