diff --git a/src/pages/messages/messages.ts b/src/pages/messages/messages.ts index 1dfcf2fb9..0f3ff93b6 100644 --- a/src/pages/messages/messages.ts +++ b/src/pages/messages/messages.ts @@ -8,6 +8,7 @@ import { _ } from 'meteor/underscore'; import { MessagesOptionsComponent } from './messages-options'; import { Subscription, Observable, Subscriber } from 'rxjs'; import { MessagesAttachmentsComponent } from './messages-attachments'; +import { PictureService } from '../../services/picture'; @Component({ selector: 'messages-page', @@ -29,7 +30,8 @@ export class MessagesPage implements OnInit, OnDestroy { constructor( navParams: NavParams, private el: ElementRef, - private popoverCtrl: PopoverController + private popoverCtrl: PopoverController, + private pictureService: PictureService ) { this.selectedChat = navParams.get('chat'); this.title = this.selectedChat.title; @@ -236,12 +238,25 @@ export class MessagesPage implements OnInit, OnDestroy { const location = params.selectedLocation; this.sendLocationMessage(location); } + else if (params.messageType === MessageType.PICTURE) { + const blob: Blob = params.selectedPicture; + this.sendPictureMessage(blob); + } } }); popover.present(); } + sendPictureMessage(blob: Blob): void { + this.pictureService.upload(blob).then((picture) => { + MeteorObservable.call('addMessage', MessageType.PICTURE, + this.selectedChat._id, + picture.url + ).zone().subscribe(); + }); + } + getLocation(locationString: string): Location { const splitted = locationString.split(',').map(Number);