Skip to content

Commit

Permalink
Step 13.10: Implement the actual send of picture message
Browse files Browse the repository at this point in the history
  • Loading branch information
dotansimha authored and darkbasic committed Oct 16, 2017
1 parent 6f6a8a8 commit 164a483
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion src/pages/messages/messages.ts
Expand Up @@ -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',
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: 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);

Expand Down

0 comments on commit 164a483

Please sign in to comment.