Permalink
Browse files

Step 13.9: Implement the actual send of picture message

  • Loading branch information...
dotansimha authored and darkbasic committed Jan 24, 2017
1 parent 86ddc1c commit 110e8488879763a45e8702db1e06abcd45950eb0
Showing with 16 additions and 1 deletion.
  1. +16 −1 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 = <Chat>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: File = params.selectedPicture;
this.sendPictureMessage(blob);
}
}
});
popover.present();
}
sendPictureMessage(blob: File): 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);

0 comments on commit 110e848

Please sign in to comment.