Skip to content
Permalink
Browse files

fix inverted first show

  • Loading branch information...
xcarpentier committed Jul 15, 2019
1 parent a81c5e3 commit 3877d1fdabbc8e1110506fec7cbda2f1d59c32bb
Showing with 346 additions and 134 deletions.
  1. +16 βˆ’12 App.js
  2. +244 βˆ’100 example-expo/data/messages.js
  3. +1 βˆ’1 package.json
  4. +5 βˆ’5 src/GiftedChat.tsx
  5. +8 βˆ’2 src/Message.tsx
  6. +6 βˆ’5 src/MessageContainer.tsx
  7. +52 βˆ’0 src/types.web.ts
  8. +1 βˆ’1 tsconfig.json
  9. +8 βˆ’0 types.d.ts
  10. +5 βˆ’8 yarn.lock
28 App.js
@@ -45,7 +45,7 @@ export default class App extends Component {
this._isMounted = true
// init with only system messages
this.setState({
messages: messagesData.filter(message => message.system),
messages: messagesData, // messagesData.filter(message => message.system),
appIsReady: true,
})
}
@@ -68,6 +68,7 @@ export default class App extends Component {
messages: GiftedChat.prepend(
previousState.messages,
earlierMessages,
Platform.OS !== 'web',
),
loadEarlier: false,
isLoadingEarlier: false,
@@ -85,13 +86,13 @@ export default class App extends Component {
messages: GiftedChat.append(
previousState.messages,
sentMessages,
this.state.inverted,
Platform.OS !== 'web',
),
step,
}
})
// for demo purpose
setTimeout(() => this.botSend(step), Math.round(Math.random() * 1000))
// setTimeout(() => this.botSend(step), Math.round(Math.random() * 1000))
}

botSend = (step = 0) => {
@@ -104,7 +105,7 @@ export default class App extends Component {
messages: GiftedChat.append(
previousState.messages,
newMessage,
this.state.inverted,
Platform.OS !== 'web',
),
}))
}
@@ -127,12 +128,16 @@ export default class App extends Component {
onReceive = text => {
this.setState(previousState => {
return {
messages: GiftedChat.append(previousState.messages, {
_id: Math.round(Math.random() * 1000000),
text,
createdAt: new Date(),
user: otherUser,
}),
messages: GiftedChat.append(
previousState.messages,
{
_id: Math.round(Math.random() * 1000000),
text,
createdAt: new Date(),
user: otherUser,
},
Platform.OS !== 'web',
),
}
})
}
@@ -194,7 +199,6 @@ export default class App extends Component {
// }

onQuickReply = replies => {
console.log({ replies })
const createdAt = new Date()
if (replies.length === 1) {
this.onSend([
@@ -251,7 +255,7 @@ export default class App extends Component {
renderCustomView={this.renderCustomView}
quickReplyStyle={{ borderRadius: 2 }}
renderQuickReplySend={this.renderQuickReplySend}
inverted={false}
inverted={Platform.OS !== 'web'}
timeTextStyle={{ left: { color: 'red' }, right: { color: 'yellow' } }}
/>
</View>

0 comments on commit 3877d1f

Please sign in to comment.
You can’t perform that action at this time.