Permalink
Browse files

Step 13.10: Implement the actual send of picture message

  • Loading branch information...
dotansimha authored and darkbasic committed Jan 24, 2017
1 parent 6f6a8a8 commit 164a483660725aeed19f38f63dfe52912709622e
Showing with 16 additions and 1 deletion.
  1. +16 −1 src/pages/messages/messages.ts
@@ -8,6 +8,7 @@ import * as _ from 'lodash';
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 164a483

Please sign in to comment.