@@ -8,6 +8,7 @@ import * as _ from 'lodash';
88import { MessagesOptionsComponent } from './messages-options' ;
99import { Subscription , Observable , Subscriber } from 'rxjs' ;
1010import { MessagesAttachmentsComponent } from './messages-attachments' ;
11+ import { PictureService } from '../../services/picture' ;
1112
1213@Component ( {
1314 selector : 'messages-page' ,
@@ -29,7 +30,8 @@ export class MessagesPage implements OnInit, OnDestroy {
2930 constructor (
3031 navParams : NavParams ,
3132 private el : ElementRef ,
32- private popoverCtrl : PopoverController
33+ private popoverCtrl : PopoverController ,
34+ private pictureService : PictureService
3335 ) {
3436 this . selectedChat = < Chat > navParams . get ( 'chat' ) ;
3537 this . title = this . selectedChat . title ;
@@ -236,12 +238,25 @@ export class MessagesPage implements OnInit, OnDestroy {
236238 const location = params . selectedLocation ;
237239 this . sendLocationMessage ( location ) ;
238240 }
241+ else if ( params . messageType === MessageType . PICTURE ) {
242+ const blob : File = params . selectedPicture ;
243+ this . sendPictureMessage ( blob ) ;
244+ }
239245 }
240246 } ) ;
241247
242248 popover . present ( ) ;
243249 }
244250
251+ sendPictureMessage ( blob : File ) : void {
252+ this . pictureService . upload ( blob ) . then ( ( picture ) => {
253+ MeteorObservable . call ( 'addMessage' , MessageType . PICTURE ,
254+ this . selectedChat . _id ,
255+ picture . url
256+ ) . zone ( ) . subscribe ( ) ;
257+ } ) ;
258+ }
259+
245260 getLocation ( locationString : string ) : Location {
246261 const splitted = locationString . split ( ',' ) . map ( Number ) ;
247262
0 commit comments