Skip to content

Commit d676134

Browse files
committed
fix receive message do not update bug
1 parent 0e67900 commit d676134

File tree

1 file changed

+8
-4
lines changed
  • ionic/example/src/pages/chat

1 file changed

+8
-4
lines changed

ionic/example/src/pages/chat/chat.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import { Component, ViewChild } from '@angular/core';
1+
import { Component, ViewChild, ChangeDetectorRef } from '@angular/core';
22
import { NavController, ModalController, NavParams, Platform, LoadingController, Loading, Content } from 'ionic-angular';
3-
import { JMessagePlugin, JMConversationInfo, JMError, JMUserInfo, JMGroupInfo, JMAllMessage, JMImageMessage, JMAllType, JMVoiceMessage } from '@jiguang-ionic/jmessage';
3+
import { JMessagePlugin, JMConversationInfo, JMError, JMUserInfo, JMGroupInfo, JMAllMessage, JMImageMessage, JMAllType, JMVoiceMessage, JMNormalMessage } from '@jiguang-ionic/jmessage';
44
import { JsonPipe } from '@angular/common';
55

66
import { File, IWriteOptions } from '@ionic-native/file';
@@ -41,7 +41,8 @@ export class ChatPage {
4141
private camera: Camera,
4242
public loadingCtrl: LoadingController,
4343
private media: Media,
44-
private file: File) {
44+
private file: File,
45+
private cd: ChangeDetectorRef,) {
4546

4647
this.conversation = <JMConversationInfo>(new Object(navParams['data']));
4748

@@ -59,16 +60,19 @@ export class ChatPage {
5960
if (this.isThisConversationMessage(message)) {
6061

6162
if (message.type == 'image') {
62-
6363
this.getImageDataFromPath(`file://${(<JMImageMessage>message).thumbPath}`).then(res => {
6464
this.imageMap[message.id] = res;
6565

6666
this.messageList.push(message);
67+
this.cd.detectChanges();
68+
this.scrollToBottom();
6769
}).catch(err => {
6870
alert(JSON.parse(err));
6971
});
7072
} else {
7173
this.messageList.push(message);
74+
this.cd.detectChanges();
75+
this.scrollToBottom();
7276
}
7377
}
7478
})

0 commit comments

Comments
 (0)