]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - client/src/app/header/suggestions.component.ts
Improve search typeahead performance and use native events
[github/Chocobozzz/PeerTube.git] / client / src / app / header / suggestions.component.ts
CommitLineData
9b8a7aa8 1import { Input, QueryList, Component, Output, AfterViewInit, EventEmitter, ViewChildren, ChangeDetectionStrategy } from '@angular/core'
6af662a5
RK
2import { SuggestionComponent } from './suggestion.component'
3
4@Component({
5 selector: 'my-suggestions',
9b8a7aa8
RK
6 templateUrl: './suggestions.component.html',
7 changeDetection: ChangeDetectionStrategy.OnPush
6af662a5
RK
8})
9export class SuggestionsComponent implements AfterViewInit {
10 @Input() results: any[]
11 @Input() highlight: string
12 @ViewChildren(SuggestionComponent) listItems: QueryList<SuggestionComponent>
13 @Output() init = new EventEmitter()
14
15 ngAfterViewInit () {
6af662a5 16 this.listItems.changes.subscribe(
9b8a7aa8 17 _ => this.init.emit({ items: this.listItems })
6af662a5
RK
18 )
19 }
20
21 hoverItem (index: number) {
22 this.init.emit({ items: this.listItems, index: index })
23 }
24}