Skip to content

Commit 164a483

Browse files
dotansimhadarkbasic
authored andcommitted
Step 13.10: Implement the actual send of picture message
1 parent 6f6a8a8 commit 164a483

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

src/pages/messages/messages.ts

+16-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import * as _ from 'lodash';
88
import { MessagesOptionsComponent } from './messages-options';
99
import { Subscription, Observable, Subscriber } from 'rxjs';
1010
import { MessagesAttachmentsComponent } from './messages-attachments';
11+
import { PictureService } from '../../services/picture';
1112

1213
@Component({
1314
selector: 'messages-page',
@@ -29,7 +30,8 @@ export class MessagesPage implements OnInit, OnDestroy {
2930
constructor(
3031
navParams: NavParams,
3132
private el: ElementRef,
32-
private popoverCtrl: PopoverController
33+
private popoverCtrl: PopoverController,
34+
private pictureService: PictureService
3335
) {
3436
this.selectedChat = <Chat>navParams.get('chat');
3537
this.title = this.selectedChat.title;
@@ -236,12 +238,25 @@ export class MessagesPage implements OnInit, OnDestroy {
236238
const location = params.selectedLocation;
237239
this.sendLocationMessage(location);
238240
}
241+
else if (params.messageType === MessageType.PICTURE) {
242+
const blob: File = params.selectedPicture;
243+
this.sendPictureMessage(blob);
244+
}
239245
}
240246
});
241247

242248
popover.present();
243249
}
244250

251+
sendPictureMessage(blob: File): void {
252+
this.pictureService.upload(blob).then((picture) => {
253+
MeteorObservable.call('addMessage', MessageType.PICTURE,
254+
this.selectedChat._id,
255+
picture.url
256+
).zone().subscribe();
257+
});
258+
}
259+
245260
getLocation(locationString: string): Location {
246261
const splitted = locationString.split(',').map(Number);
247262

0 commit comments

Comments
 (0)