X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=client%2Fsrc%2Fapp%2Fheader%2Fsearch-typeahead.component.ts;h=e10baea2b967a5a98ba0f5bf84a7b214144dad4b;hb=9df52d660feb722404be00a50f3c8a612bec1c15;hp=7d04e0f6d42b616535e896e332b334898378c6b6;hpb=3b0bd70aa05ab82fa30fe67ed4899d44652c703a;p=github%2FChocobozzz%2FPeerTube.git diff --git a/client/src/app/header/search-typeahead.component.ts b/client/src/app/header/search-typeahead.component.ts index 7d04e0f6d..e10baea2b 100644 --- a/client/src/app/header/search-typeahead.component.ts +++ b/client/src/app/header/search-typeahead.component.ts @@ -1,11 +1,10 @@ import { of } from 'rxjs' -import { first, tap, delay } from 'rxjs/operators' +import { first, tap } from 'rxjs/operators' import { ListKeyManager } from '@angular/cdk/a11y' -import { AfterViewInit, Component, ElementRef, OnDestroy, OnInit, QueryList, ViewChild, ViewChildren, AfterViewChecked } 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 { ServerConfig } from '@shared/models' -import { SearchTargetType } from '@shared/models/search/search-target-query.model' +import { HTMLServerConfig, SearchTargetType } from '@shared/models' import { SuggestionComponent, SuggestionPayload, SuggestionPayloadType } from './suggestion.component' @Component({ @@ -13,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 @@ -21,7 +20,7 @@ export class SearchTypeaheadComponent implements OnInit, AfterViewInit, AfterVie areSuggestionsOpened = true search = '' - serverConfig: ServerConfig + serverConfig: HTMLServerConfig inThisChannelText: string @@ -43,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() - }) }) } @@ -206,7 +199,7 @@ export class SearchTypeaheadComponent implements OnInit, AfterViewInit, AfterVie } private loadUserLanguagesIfNeeded (queryParams: any) { - if (queryParams && queryParams.languageOneOf) return of(queryParams) + if (queryParams?.languageOneOf) return of(queryParams) return this.authService.userInformationLoaded .pipe(