1- import { Component , ViewChild } from '@angular/core' ;
1+ import { Component , ViewChild , ChangeDetectorRef } from '@angular/core' ;
22import { 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' ;
44import { JsonPipe } from '@angular/common' ;
55
66import { 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