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 13, 2017
1 parent cc4e4fa commit 9da1569
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions src/pages/messages/messages.ts
@@ -1,6 +1,6 @@
import { Component, OnInit, OnDestroy, ElementRef } from '@angular/core';
import { NavParams, PopoverController } from 'ionic-angular';
import { Chat, Message, MessageType } from 'api/models';
import { Chat, Message, MessageType, Location } from 'api/models';
import { Messages } from 'api/collections';
import { MeteorObservable } from 'meteor-rxjs';
import * as moment from 'moment';
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 9da1569

Please sign in to comment.