From 2989628b7913383b39ac34c7db8666a21f8e5037 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 4 Jun 2021 13:31:41 +0200 Subject: Use HTML config when possible --- .../src/app/header/search-typeahead.component.ts | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) (limited to 'client/src/app/header') diff --git a/client/src/app/header/search-typeahead.component.ts b/client/src/app/header/search-typeahead.component.ts index c546628ee..b5d76c70e 100644 --- a/client/src/app/header/search-typeahead.component.ts +++ b/client/src/app/header/search-typeahead.component.ts @@ -1,10 +1,10 @@ import { of } from 'rxjs' import { first, tap } from 'rxjs/operators' import { ListKeyManager } from '@angular/cdk/a11y' -import { AfterViewChecked, AfterViewInit, Component, OnDestroy, OnInit, QueryList, ViewChildren } from '@angular/core' +import { AfterViewChecked, Component, OnDestroy, OnInit, QueryList, ViewChildren } from '@angular/core' import { ActivatedRoute, Params, Router } from '@angular/router' import { AuthService, ServerService } from '@app/core' -import { SearchTargetType, ServerConfig } from '@shared/models' +import { HTMLServerConfig, SearchTargetType } from '@shared/models' import { SuggestionComponent, SuggestionPayload, SuggestionPayloadType } from './suggestion.component' @Component({ @@ -12,7 +12,7 @@ import { SuggestionComponent, SuggestionPayload, SuggestionPayloadType } from '. templateUrl: './search-typeahead.component.html', styleUrls: [ './search-typeahead.component.scss' ] }) -export class SearchTypeaheadComponent implements OnInit, AfterViewInit, AfterViewChecked, OnDestroy { +export class SearchTypeaheadComponent implements OnInit, AfterViewChecked, OnDestroy { @ViewChildren(SuggestionComponent) suggestionItems: QueryList hasChannel = false @@ -20,7 +20,7 @@ export class SearchTypeaheadComponent implements OnInit, AfterViewInit, AfterVie areSuggestionsOpened = true search = '' - serverConfig: ServerConfig + serverConfig: HTMLServerConfig inThisChannelText: string @@ -42,20 +42,14 @@ export class SearchTypeaheadComponent implements OnInit, AfterViewInit, AfterVie this.route.queryParams .pipe(first(params => this.isOnSearch() && params.search !== undefined && params.search !== null)) .subscribe(params => this.search = params.search) - } - ngAfterViewInit () { - this.serverService.getConfig() + this.serverConfig = this.serverService.getHTMLConfig() + this.computeTypeahead() + + this.serverService.configReloaded .subscribe(config => { this.serverConfig = config - this.computeTypeahead() - - this.serverService.configReloaded - .subscribe(config => { - this.serverConfig = config - this.computeTypeahead() - }) }) } -- cgit v1.2.3