Skip to content

Commit

Permalink
Step 12.19: Implement send location message
Browse files Browse the repository at this point in the history
  • Loading branch information
dotansimha authored and darkbasic committed Jun 13, 2017
1 parent 31926e4 commit 4f4b2a9
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 4f4b2a9

Please sign in to comment.