Skip to content

Commit

Permalink
Step 12.8: Implement the actual send of picture message
Browse files Browse the repository at this point in the history
  • Loading branch information
dotansimha authored and DAB0mB committed Feb 26, 2017
1 parent 3e659d6 commit 511489b
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion client/imports/pages/messages/messages.ts
Expand Up @@ -6,6 +6,7 @@ import * as Moment from 'moment';
import { Observable, Subscription, Subscriber } from 'rxjs';
import { Messages } from '../../../../imports/collections';
import { Chat, Message, MessageType, Location } from '../../../../imports/models';
import { PictureService } from '../../services/picture';
import { MessagesAttachmentsComponent } from './messages-attachments';
import { MessagesOptionsComponent } from './messages-options';
import template from './messages.html';
Expand All @@ -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;
Expand Down Expand Up @@ -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);

Expand Down

0 comments on commit 511489b

Please sign in to comment.