- this.searchInput = this.contentWrapper.nativeElement.childNodes[0]
- this.searchInput.addEventListener('input', this.computeResults.bind(this))
+ this.serverService.getConfig()
+ .subscribe(config => {
+ this.serverConfig = config
+
+ this.computeTypeahead()
+
+ this.serverService.configReloaded
+ .subscribe(config => {
+ this.serverConfig = config
+ this.computeTypeahead()
+ })
+ })
+ }
+
+ ngAfterViewChecked () {
+ if (this.scheduleKeyboardEventsInit && !this.keyboardEventsManager) {
+ // Avoid ExpressionChangedAfterItHasBeenCheckedError errors
+ setTimeout(() => this.initKeyboardEventsManager(), 0)
+ }
+ }
+
+ ngOnDestroy () {
+ if (this.keyboardEventsManager) this.keyboardEventsManager.change.unsubscribe()
+ }
+
+ areInstructionsDisplayed () {
+ return !this.search
+ }
+
+ showSearchGlobalHelp () {
+ return this.search && this.areSuggestionsOpened && this.keyboardEventsManager?.activeItem?.result?.type === 'search-index'
+ }
+
+ canSearchAnyURI () {
+ if (!this.serverConfig) return false
+
+ return this.authService.isLoggedIn()
+ ? this.serverConfig.search.remoteUri.users
+ : this.serverConfig.search.remoteUri.anonymous