Permalink
Browse files

Step 12.19: Implement send location message

  • Loading branch information...
dotansimha authored and darkbasic committed Jan 24, 2017
1 parent c2c0d32 commit a337c835e0c51b7b66b722238e7ae26da2126e8f
Showing with 17 additions and 2 deletions.
  1. +17 −2 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';
@@ -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
@@ -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();

0 comments on commit a337c83

Please sign in to comment.