-import { forkJoin, Subscription } from 'rxjs'
+import { forkJoin, Subject, Subscription } from 'rxjs'
import { LinkType } from 'src/types/link.type'
import { Component, OnDestroy, OnInit } from '@angular/core'
import { ActivatedRoute, Router } from '@angular/router'
userMiniature: User
+ onSearchDataSubject = new Subject<any>()
+
private subActivatedRoute: Subscription
private isInitialLoad = false // set to false to show the search filters on first arrival
- private channelsPerPage = 2
- private playlistsPerPage = 2
- private videosPerPage = 10
-
private hasMoreResults = true
private isSearching = false
this.search()
},
- error: err => this.notifier.error(err.text)
+ error: err => this.notifier.error(err.message)
})
this.userService.getAnonymousOrLoggedUser()
this.lastSearchTarget = this.advancedSearch.searchTarget
this.hasMoreResults = this.results.length < this.pagination.totalItems
+
+ this.onSearchDataSubject.next(results)
},
error: err => {
private resetPagination () {
this.pagination.currentPage = 1
this.pagination.totalItems = null
- this.channelsPerPage = 2
this.results = []
}
private updateTitle () {
- const suffix = this.currentSearch
- ? ' ' + this.currentSearch
- : ''
+ const title = this.currentSearch
+ ? $localize`Search ${this.currentSearch}`
+ : $localize`Search`
- this.metaService.setTitle($localize`Search` + suffix)
+ this.metaService.setTitle(title)
}
private updateUrlFromAdvancedSearch () {
private getVideosObs () {
const params = {
search: this.currentSearch,
- componentPagination: immutableAssign(this.pagination, { itemsPerPage: this.videosPerPage }),
+ componentPagination: immutableAssign(this.pagination, { itemsPerPage: 10 }),
advancedSearch: this.advancedSearch
}
private getVideoChannelObs () {
const params = {
search: this.currentSearch,
- componentPagination: immutableAssign(this.pagination, { itemsPerPage: this.channelsPerPage }),
+ componentPagination: immutableAssign(this.pagination, { itemsPerPage: this.buildChannelsPerPage() }),
advancedSearch: this.advancedSearch
}
private getVideoPlaylistObs () {
const params = {
search: this.currentSearch,
- componentPagination: immutableAssign(this.pagination, { itemsPerPage: this.playlistsPerPage }),
+ componentPagination: immutableAssign(this.pagination, { itemsPerPage: this.buildPlaylistsPerPage() }),
advancedSearch: this.advancedSearch
}
return undefined
}
+
+ private buildChannelsPerPage () {
+ if (this.advancedSearch.resultType === 'channels') return 10
+
+ return 2
+ }
+
+ private buildPlaylistsPerPage () {
+ if (this.advancedSearch.resultType === 'playlists') return 10
+
+ return 2
+ }
}