From 4e1246731eb18f52be4dae38df8c7ee4eb43ba30 Mon Sep 17 00:00:00 2001 From: Richard Park Date: Tue, 8 Oct 2019 13:31:33 +0900 Subject: [PATCH] message list is implemented --- .../components/messages.component.html | 5 +++- .../components/messages.component.ts | 30 +++++++++++++++++-- .../lib/components/messages.component.html | 12 ++++---- .../src/lib/components/messages.component.ts | 7 ++++- 4 files changed, 44 insertions(+), 10 deletions(-) diff --git a/projects/ucap-webmessenger-app/src/app/layouts/messenger/components/messages.component.html b/projects/ucap-webmessenger-app/src/app/layouts/messenger/components/messages.component.html index 18ebf834..cc6ca76e 100644 --- a/projects/ucap-webmessenger-app/src/app/layouts/messenger/components/messages.component.html +++ b/projects/ucap-webmessenger-app/src/app/layouts/messenger/components/messages.component.html @@ -38,7 +38,10 @@
- +
diff --git a/projects/ucap-webmessenger-app/src/app/layouts/messenger/components/messages.component.ts b/projects/ucap-webmessenger-app/src/app/layouts/messenger/components/messages.component.ts index a387b36c..558fbf8c 100644 --- a/projects/ucap-webmessenger-app/src/app/layouts/messenger/components/messages.component.ts +++ b/projects/ucap-webmessenger-app/src/app/layouts/messenger/components/messages.component.ts @@ -1,5 +1,14 @@ import { Component, OnInit } from '@angular/core'; import { ucapAnimations } from '@ucap-webmessenger/ui'; +import { Store, select } from '@ngrx/store'; +import { NGXLogger } from 'ngx-logger'; +import { Observable } from 'rxjs'; +import { Info } from '@ucap-webmessenger/protocol-event'; + +import * as AppStore from '@app/store'; +import { LoginResponse } from '@ucap-webmessenger/protocol-authentication'; +import { SessionStorageService } from '@ucap-webmessenger/web-storage'; +import { LoginInfo, KEY_LOGIN_INFO } from '@app/types'; @Component({ selector: 'app-layout-messenger-messages', @@ -8,9 +17,26 @@ import { ucapAnimations } from '@ucap-webmessenger/ui'; animations: ucapAnimations }) export class MessagesComponent implements OnInit { - constructor() {} + loginRes$: Observable; + eventList$: Observable; - ngOnInit() {} + constructor( + private store: Store, + private sessionStorageService: SessionStorageService, + private logger: NGXLogger + ) {} + + ngOnInit() { + const loginInfo = this.sessionStorageService.get(KEY_LOGIN_INFO); + + this.loginRes$ = this.store.pipe( + select(AppStore.AccountSelector.AuthenticationSelector.loginRes) + ); + + this.eventList$ = this.store.pipe( + select(AppStore.MessengerSelector.EventSelector.infoList) + ); + } selectContact() {} } diff --git a/projects/ucap-webmessenger-ui-chat/src/lib/components/messages.component.html b/projects/ucap-webmessenger-ui-chat/src/lib/components/messages.component.html index 6441b2be..48fefc64 100644 --- a/projects/ucap-webmessenger-ui-chat/src/lib/components/messages.component.html +++ b/projects/ucap-webmessenger-ui-chat/src/lib/components/messages.component.html @@ -4,17 +4,17 @@ *ngFor="let message of messages; let i = index" class="message-row" [ngClass]="{ - me: message.who === user.id, - contact: message.who !== user.id, - 'first-of-group': isFirstMessageOfGroup(message, i), - 'last-of-group': isLastMessageOfGroup(message, i) + me: message.senderSeq === loginRes.userSeq, + contact: message.senderSeq !== loginRes.userSeq }" >
-
{{ message.message }}
-
{{ message.time | date: 'short' }}
+
{{ message.sentMessage }}
+
+ {{ message.sendDate | date: 'short' }} +
diff --git a/projects/ucap-webmessenger-ui-chat/src/lib/components/messages.component.ts b/projects/ucap-webmessenger-ui-chat/src/lib/components/messages.component.ts index 6a1f843c..2833e519 100644 --- a/projects/ucap-webmessenger-ui-chat/src/lib/components/messages.component.ts +++ b/projects/ucap-webmessenger-ui-chat/src/lib/components/messages.component.ts @@ -1,5 +1,8 @@ import { Component, OnInit, Input } from '@angular/core'; +import { Info } from '@ucap-webmessenger/protocol-event'; +import { LoginResponse } from '@ucap-webmessenger/protocol-authentication'; + @Component({ selector: 'ucap-chat-messages', templateUrl: './messages.component.html', @@ -7,7 +10,9 @@ import { Component, OnInit, Input } from '@angular/core'; }) export class MessagesComponent implements OnInit { @Input() - messages: any[]; + loginRes: LoginResponse; + @Input() + messages: Info[]; constructor() {}