@@ -8,6 +8,7 @@ import * as _ from 'lodash';
8
8
import { MessagesOptionsComponent } from './messages-options' ;
9
9
import { Subscription , Observable , Subscriber } from 'rxjs' ;
10
10
import { MessagesAttachmentsComponent } from './messages-attachments' ;
11
+ import { PictureService } from '../../services/picture' ;
11
12
12
13
@Component ( {
13
14
selector : 'messages-page' ,
@@ -29,7 +30,8 @@ export class MessagesPage implements OnInit, OnDestroy {
29
30
constructor (
30
31
navParams : NavParams ,
31
32
private el : ElementRef ,
32
- private popoverCtrl : PopoverController
33
+ private popoverCtrl : PopoverController ,
34
+ private pictureService : PictureService
33
35
) {
34
36
this . selectedChat = < Chat > navParams . get ( 'chat' ) ;
35
37
this . title = this . selectedChat . title ;
@@ -236,12 +238,25 @@ export class MessagesPage implements OnInit, OnDestroy {
236
238
const location = params . selectedLocation ;
237
239
this . sendLocationMessage ( location ) ;
238
240
}
241
+ else if ( params . messageType === MessageType . PICTURE ) {
242
+ const blob : File = params . selectedPicture ;
243
+ this . sendPictureMessage ( blob ) ;
244
+ }
239
245
}
240
246
} ) ;
241
247
242
248
popover . present ( ) ;
243
249
}
244
250
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
+
245
260
getLocation ( locationString : string ) : Location {
246
261
const splitted = locationString . split ( ',' ) . map ( Number ) ;
247
262
0 commit comments