import { LinkType } from 'src/types/link.type'
import { Component, OnDestroy, OnInit } from '@angular/core'
import { ActivatedRoute, Router } from '@angular/router'
import { AuthService, HooksService, MetaService, Notifier, ServerService, User, UserService } from '@app/core'
import { immutableAssign } from '@app/helpers'
import { LinkType } from 'src/types/link.type'
import { Component, OnDestroy, OnInit } from '@angular/core'
import { ActivatedRoute, Router } from '@angular/router'
import { AuthService, HooksService, MetaService, Notifier, ServerService, User, UserService } from '@app/core'
import { immutableAssign } from '@app/helpers'
import { Video, VideoChannel } from '@app/shared/shared-main'
import { AdvancedSearch, SearchService } from '@app/shared/shared-search'
import { MiniatureDisplayOptions } from '@app/shared/shared-video-miniature'
import { Video, VideoChannel } from '@app/shared/shared-main'
import { AdvancedSearch, SearchService } from '@app/shared/shared-search'
import { MiniatureDisplayOptions } from '@app/shared/shared-video-miniature'
templateUrl: './search.component.html'
})
export class SearchComponent implements OnInit, OnDestroy {
templateUrl: './search.component.html'
})
export class SearchComponent implements OnInit, OnDestroy {
private subActivatedRoute: Subscription
private isInitialLoad = false // set to false to show the search filters on first arrival
private subActivatedRoute: Subscription
private isInitialLoad = false // set to false to show the search filters on first arrival
- this.subActivatedRoute = this.route.queryParams.subscribe(
- async queryParams => {
- const querySearch = queryParams['search']
- const searchTarget = queryParams['searchTarget']
+ this.subActivatedRoute = this.route.queryParams
+ .subscribe({
+ next: queryParams => {
+ const querySearch = queryParams['search']
+ const searchTarget = queryParams['searchTarget']
- // Search updated, reset filters
- if (this.currentSearch !== querySearch || searchTarget !== this.advancedSearch.searchTarget) {
- this.resetPagination()
- this.advancedSearch.reset()
+ // Search updated, reset filters
+ if (this.currentSearch !== querySearch || searchTarget !== this.advancedSearch.searchTarget) {
+ this.resetPagination()
+ this.advancedSearch.reset()
- this.advancedSearch = new AdvancedSearch(queryParams)
- if (!this.advancedSearch.searchTarget) {
- this.advancedSearch.searchTarget = this.getDefaultSearchTarget()
- }
+ this.advancedSearch = new AdvancedSearch(queryParams)
+ if (!this.advancedSearch.searchTarget) {
+ this.advancedSearch.searchTarget = this.getDefaultSearchTarget()
+ }
- // Don't hide filters if we have some of them AND the user just came on the webpage
- this.isSearchFilterCollapsed = this.isInitialLoad === false || !this.advancedSearch.containsValues()
- this.isInitialLoad = false
+ this.error = this.checkFieldsAndGetError()
this.isSearching = true
forkJoin([
this.getVideoChannelObs(),
this.getVideoPlaylistObs(),
this.getVideosObs()
this.isSearching = true
forkJoin([
this.getVideoChannelObs(),
this.getVideoPlaylistObs(),
this.getVideosObs()
- ]).subscribe(results => {
- for (const result of results) {
- this.results = this.results.concat(result.data)
- }
+ ]).subscribe({
+ next: results => {
+ for (const result of results) {
+ this.results = this.results.concat(result.data)
+ }
- this.pagination.totalItems = results.reduce((p, r) => p += r.total, 0)
- this.lastSearchTarget = this.advancedSearch.searchTarget
+ this.pagination.totalItems = results.reduce((p, r) => p += r.total, 0)
+ this.lastSearchTarget = this.advancedSearch.searchTarget
- this.notifier.error(
- $localize`Search index is unavailable. Retrying with instance results instead.`,
- $localize`Search error`
- )
- this.advancedSearch.searchTarget = 'local'
- this.search()
- },
+ this.notifier.error(
+ $localize`Search index is unavailable. Retrying with instance results instead.`,
+ $localize`Search error`
+ )
+ this.advancedSearch.searchTarget = 'local'
+ this.search()
+ },
const params = {
search: this.currentSearch,
componentPagination: immutableAssign(this.pagination, { itemsPerPage: this.channelsPerPage }),
const params = {
search: this.currentSearch,
componentPagination: immutableAssign(this.pagination, { itemsPerPage: this.channelsPerPage }),
const params = {
search: this.currentSearch,
componentPagination: immutableAssign(this.pagination, { itemsPerPage: this.playlistsPerPage }),
const params = {
search: this.currentSearch,
componentPagination: immutableAssign(this.pagination, { itemsPerPage: this.playlistsPerPage }),