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 5b0c7537..2d33ee3f 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,24 +1,37 @@
- - - - +
+ + + + + {{ filteredRecommendedWord }} + + + + + +
, + private formBuilder: FormBuilder, private logger: NGXLogger, private sessionStorageService: SessionStorageService ) { this.sessionVerinfo = this.sessionStorageService.get( KEY_VER_INFO ); + this.recommendedWordList = []; } - isSearch = false; - searchWord = ''; - ngOnInit() { + this.fgSearch = this.formBuilder.group({ + searchInput: null + }); + + this.fgSearch + .get('searchInput') + .valueChanges.pipe(debounceTime(300)) + .subscribe(value => { + if (value !== null && value.length > 0) { + this.filteredRecommendedWordList = this.recommendedWordList.filter( + v => { + return v.includes(value); + } + ); + } else { + this.filteredRecommendedWordList = []; + } + }); + this.roomSubscription = combineLatest([ this.store.pipe( select(AppStore.MessengerSelector.SyncSelector.selectAllRoom) @@ -73,6 +98,33 @@ export class ChatComponent implements OnInit, OnDestroy { this.roomList = room; this.roomUserList = roomUser; this.roomUserShortList = roomUserShort; + + const recommendedWordList = []; + for (const r of room) { + if (!!r.roomName && '' !== r.roomName.trim()) { + recommendedWordList.push(r.roomName); + } + } + for (const ru of roomUser) { + for (const u of ru.userInfos) { + if (u.seq !== this.loginRes.userSeq) { + if (!!u.name && '' !== u.name.trim()) { + recommendedWordList.push(u.name); + } + } + } + } + for (const ru of roomUserShort) { + for (const u of ru.userInfos) { + if (u.seq !== this.loginRes.userSeq) { + if (!!u.name && '' !== u.name.trim()) { + recommendedWordList.push(u.name); + } + } + } + } + + this.recommendedWordList = [...recommendedWordList]; }) ) .subscribe(); diff --git a/projects/ucap-webmessenger-app/src/app/layouts/messenger/messenger.layout.module.ts b/projects/ucap-webmessenger-app/src/app/layouts/messenger/messenger.layout.module.ts index 88ce86d8..de2f14c9 100644 --- a/projects/ucap-webmessenger-app/src/app/layouts/messenger/messenger.layout.module.ts +++ b/projects/ucap-webmessenger-app/src/app/layouts/messenger/messenger.layout.module.ts @@ -8,6 +8,7 @@ import { FlexLayoutModule } from '@angular/flex-layout'; import { ScrollingModule } from '@angular/cdk/scrolling'; +import { MatAutocompleteModule } from '@angular/material/autocomplete'; import { MatBadgeModule } from '@angular/material/badge'; import { MatButtonModule } from '@angular/material/button'; import { MatCardModule } from '@angular/material/card'; @@ -46,6 +47,8 @@ import { DIALOGS } from './dialogs'; ReactiveFormsModule, OverlayModule, ScrollingModule, + + MatAutocompleteModule, MatFormFieldModule, MatInputModule, MatBadgeModule,