@@ -197,27 +197,34 @@ export default class Chat extends Component {
197197 Alert . alert ( 'error!' , JSON . stringify ( error ) )
198198 } )
199199
200- // this.receiveMessageCallBack = (message) => {
201-
202- // if (this.conversation.conversationType === 'single') {
203- // if (message.target.type === 'user') {
204- // if (message.from.username === this.conversation.key) {
205- // var msg = this.convertJMessageToAuroraMsg(message)
206- // AuroraIController.appendMessages([msg])
207- // }
208- // Alert.alert('message.target.username', message.target.username)
209- // Alert.alert('this.conversation.key', this.conversation.key)
210- // }
211- // } else {
212- // if (message.target.type === 'group') {
213- // if (message.from.id === this.conversation.key) {
214- // var msg = this.convertJMessageToAuroraMsg(message)
215- // AuroraIController.appendMessages([msg])
216- // }
217- // }
218- // }
219- // }
220- // JMessage.addReceiveMessageListener(this.receiveMessageCallBack)
200+ this . receiveMessageCallBack = ( message ) => {
201+
202+ if ( this . conversation . conversationType === 'single' ) {
203+ if ( message . target . type === 'user' ) {
204+ if ( message . from . username === this . conversation . key ) {
205+ var msg = this . convertJMessageToAuroraMsg ( message )
206+ AuroraIController . appendMessages ( [ msg ] )
207+ }
208+ Alert . alert ( 'message.target.username' , message . target . username )
209+ Alert . alert ( 'this.conversation.key' , this . conversation . key )
210+ }
211+ } else if ( this . conversation . conversationType === 'group' ) {
212+ if ( message . target . type === 'group' ) {
213+ if ( message . from . id === this . conversation . key ) {
214+ var msg = this . convertJMessageToAuroraMsg ( message )
215+ AuroraIController . appendMessages ( [ msg ] )
216+ }
217+ }
218+ } else {
219+ if ( message . target . type === 'chatroom' ) {
220+ if ( message . target . roomId === this . conversation . key ) {
221+ var msg = this . convertJMessageToAuroraMsg ( message )
222+ AuroraIController . appendMessages ( [ msg ] )
223+ }
224+ }
225+ }
226+ }
227+ JMessage . addReceiveMessageListener ( this . receiveMessageCallBack )
221228 }
222229 AuroraIController . addMessageListDidLoadListener ( this . messageListDidLoadCallback )
223230 // this.timer = setTimeout(() => {
@@ -232,7 +239,7 @@ export default class Chat extends Component {
232239 this . setState ( {
233240 inputLayoutHeight : size . height ,
234241 inputViewLayout : { width : size . width , height : size . height } ,
235- messageListLayout : { flex :1 , width : window . width , margin : 0 }
242+ messageListLayout : { flex : 1 , width : window . width , margin : 0 }
236243 } )
237244 }
238245 }
@@ -281,14 +288,14 @@ export default class Chat extends Component {
281288 var navigationBar = 50
282289 this . setState ( {
283290 messageListLayout : { flex : 0 , width : 0 , height : 0 } ,
284- inputViewLayout : { flex :1 , width : window . width , height : window . height }
291+ inputViewLayout : { flex : 1 , width : window . width , height : window . height }
285292 } )
286293 }
287294
288295 onRecoverScreen = ( ) => {
289296 this . setState ( {
290297 messageListLayout : { flex : 1 , width : window . width , margin : 0 } ,
291- inputViewLayout : { flex : 0 , width : window . width , height : this . state . inputLayoutHeight }
298+ inputViewLayout : { flex : 0 , width : window . width , height : this . state . inputLayoutHeight }
292299 } )
293300 }
294301
0 commit comments