From 7e5bc54be1f288cefc37dd71a1f1e77405480db2 Mon Sep 17 00:00:00 2001 From: leejh Date: Wed, 23 Oct 2019 15:45:48 +0900 Subject: [PATCH] =?UTF-8?q?=EA=B8=B0=EB=8A=A5=EC=B6=94=EA=B0=80=20::=20?= =?UTF-8?q?=EB=8C=80=ED=99=94=20>=20=EA=B2=80=EC=83=89=EA=B8=B0=EB=8A=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../left-sidenav/chat.component.html | 36 +++++++++++++++++-- .../components/left-sidenav/chat.component.ts | 33 ++++++++++++++++- 2 files changed, 65 insertions(+), 4 deletions(-) diff --git a/projects/ucap-webmessenger-app/src/app/layouts/messenger/components/left-sidenav/chat.component.html b/projects/ucap-webmessenger-app/src/app/layouts/messenger/components/left-sidenav/chat.component.html index 90fd5e0f..539f541a 100644 --- a/projects/ucap-webmessenger-app/src/app/layouts/messenger/components/left-sidenav/chat.component.html +++ b/projects/ucap-webmessenger-app/src/app/layouts/messenger/components/left-sidenav/chat.component.html @@ -1,3 +1,33 @@ - - +
+ + + + +
+
+ + +
diff --git a/projects/ucap-webmessenger-app/src/app/layouts/messenger/components/left-sidenav/chat.component.ts b/projects/ucap-webmessenger-app/src/app/layouts/messenger/components/left-sidenav/chat.component.ts index 531eb7df..8f2979e7 100644 --- a/projects/ucap-webmessenger-app/src/app/layouts/messenger/components/left-sidenav/chat.component.ts +++ b/projects/ucap-webmessenger-app/src/app/layouts/messenger/components/left-sidenav/chat.component.ts @@ -46,6 +46,9 @@ export class ChatComponent implements OnInit, OnDestroy { ); } + isSearch = false; + searchWord = ''; + ngOnInit() { this.roomSubscription = combineLatest([ this.store.pipe( @@ -90,11 +93,39 @@ export class ChatComponent implements OnInit, OnDestroy { } } + onKeyDownEnter(search: string) { + if (search.trim().length > 1) { + this.isSearch = true; + this.searchWord = search; + } + } + onSelectedRoom(roomInfo: RoomInfo) { this.store.dispatch(ChatStore.selectedRoom({ roomSeq: roomInfo.roomSeq })); } - getRoomUserList(roomInfo: RoomInfo): RoomUserInfo[] | UserInfoShort[] { + getRoomList() { + if (this.isSearch && this.searchWord.trim().length > 0) { + return this.roomList.filter(room => { + if (room.roomName.indexOf(this.searchWord) >= 0) { + return true; + } + if ( + this.getRoomUserList(room).filter(user => + user.seq !== this.loginRes.userSeq + ? user.name.indexOf(this.searchWord) >= 0 + : false + ).length > 0 + ) { + return true; + } + return false; + }); + } + return this.roomList; + } + + getRoomUserList(roomInfo: RoomInfo): (RoomUserInfo | UserInfoShort)[] { if (!!this.roomUserList && 0 < this.roomUserList.length) { const i = this.roomUserList.findIndex( value => roomInfo.roomSeq === value.roomSeq