Skip to content

Commit

Permalink
Step 11.19: Implement send location 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 0ea400f commit e4f8c02
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions client/imports/pages/messages/messages.ts
Expand Up @@ -5,7 +5,7 @@ import { _ } from 'meteor/underscore';
import * as Moment from 'moment';
import { Observable, Subscription, Subscriber } from 'rxjs';
import { Messages } from '../../../../imports/collections';
import { Chat, Message, MessageType } from '../../../../imports/models';
import { Chat, Message, MessageType, Location } from '../../../../imports/models';
import { MessagesAttachmentsComponent } from './messages-attachments';
import { MessagesOptionsComponent } from './messages-options';
import template from './messages.html';
Expand Down Expand Up @@ -213,6 +213,16 @@ export class MessagesPage implements OnInit, OnDestroy {
});
}

sendLocationMessage(location: Location): void {
MeteorObservable.call('addMessage', MessageType.LOCATION,
this.selectedChat._id,
`${location.lat},${location.lng},${location.zoom}`
).zone().subscribe(() => {
// Zero the input field
this.message = '';
});
}

showAttachments(): void {
const popover = this.popoverCtrl.create(MessagesAttachmentsComponent, {
chat: this.selectedChat
Expand All @@ -221,7 +231,12 @@ export class MessagesPage implements OnInit, OnDestroy {
});

popover.onDidDismiss((params) => {
// TODO: Handle result
if (params) {
if (params.messageType === MessageType.LOCATION) {
const location = params.selectedLocation;
this.sendLocationMessage(location);
}
}
});

popover.present();
Expand Down

0 comments on commit e4f8c02

Please sign in to comment.