Skip to content

Commit 38a7a7d

Browse files
KenChoiKenChoi
authored andcommitted
message can convert to chatroom message
1 parent d10f561 commit 38a7a7d

File tree

2 files changed

+33
-24
lines changed

2 files changed

+33
-24
lines changed

android/src/io/jchat/android/utils/ResultUtils.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,8 @@ public static WritableMap toJSObject(Message msg) {
136136
result.putMap(Constant.TARGET, toJSObject((UserInfo) msg.getTargetInfo()));
137137
} else if (msg.getTargetType() == ConversationType.group) {
138138
result.putMap(Constant.TARGET, toJSObject((GroupInfo) msg.getTargetInfo()));
139+
} else {
140+
result.putMap(Constant.TARGET, toJSObject((ChatRoomInfo) msg.getTargetInfo()));
139141
}
140142

141143
} else {

example/app/routes/Chat/index.js

Lines changed: 31 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)