|
|
@ -11,17 +11,15 @@ import { Chat } from 'src/app/models/chat';
|
|
|
|
})
|
|
|
|
})
|
|
|
|
export class ChatComponent implements OnInit {
|
|
|
|
export class ChatComponent implements OnInit {
|
|
|
|
|
|
|
|
|
|
|
|
messages:Array<Chatmessage> = [new Chatmessage("Hallo", "01.01.",true), new Chatmessage("Hallo", "01.01.",true),
|
|
|
|
messages:Array<Chatmessage>
|
|
|
|
new Chatmessage("Hallo", "01.01.",true), new Chatmessage("Hallo", "01.01.",true), new Chatmessage("Hallo", "01.01.",true),
|
|
|
|
|
|
|
|
new Chatmessage("Hallo", "01.01.",true)]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Output() goBackEvent = new EventEmitter<boolean>();
|
|
|
|
@Output() goBackEvent = new EventEmitter<boolean>();
|
|
|
|
@Output() refreshEvent = new EventEmitter<boolean>()
|
|
|
|
|
|
|
|
@Input() childChat: Chat;
|
|
|
|
@Input() childChat: Chat;
|
|
|
|
|
|
|
|
|
|
|
|
constructor(private chatService: ChatService) { }
|
|
|
|
constructor(private chatService: ChatService) { }
|
|
|
|
|
|
|
|
|
|
|
|
ngOnInit() {
|
|
|
|
ngOnInit() {
|
|
|
|
|
|
|
|
this.refresh()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
goBack() {
|
|
|
|
goBack() {
|
|
|
@ -30,8 +28,20 @@ export class ChatComponent implements OnInit {
|
|
|
|
|
|
|
|
|
|
|
|
sendMessage(pElement) {
|
|
|
|
sendMessage(pElement) {
|
|
|
|
this.chatService.sendMessage(this.childChat.id, pElement.value)
|
|
|
|
this.chatService.sendMessage(this.childChat.id, pElement.value)
|
|
|
|
this.refreshEvent.emit(true)
|
|
|
|
.subscribe(response => {
|
|
|
|
pElement.value = ""
|
|
|
|
console.log("Message sent")
|
|
|
|
|
|
|
|
pElement.value = ""
|
|
|
|
|
|
|
|
this.refresh()
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
refresh() {
|
|
|
|
|
|
|
|
this.chatService.getMessagesRaw(this.childChat.id)
|
|
|
|
|
|
|
|
.subscribe(response =>
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
console.log("Downloading messages ...")
|
|
|
|
|
|
|
|
this.messages = this.chatService.renderMessages(response.json())
|
|
|
|
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|