Make message timestamps optional

This commit is contained in:
Kristóf Tóth 2018-06-25 18:10:25 +02:00
parent ef4f467457
commit f9ac60b270
2 changed files with 12 additions and 5 deletions

View File

@ -3,5 +3,5 @@
export class MessageMetadata {
originator: string;
timestamp: Date;
timestamp?: Date;
}

View File

@ -55,17 +55,24 @@ export class MessagesComponent implements OnInit {
);
}
writeMessage(data: MessagesMessage) {
data.message = this.convert(data.message);
this.messages.push(data);
writeMessage(message: MessagesMessage) {
this.transformMessage(message);
this.messages.push(message);
this.changeDetectorRef.detectChanges();
}
transformMessage(message: MessagesMessage) {
message.message = this.convertMarkdownToHTML(message.message);
if (!message.timestamp) {
message.timestamp = new Date();
}
}
handleQueueMessage(data: MessageQueueMessage) {
this.messageQueueAttender.queueMessages(data.messages);
}
convert(text: string) {
convertMarkdownToHTML(text: string) {
return this.markdownService.convertToHtml(text);
}