diff options
Diffstat (limited to 'client/src/app/+search/search.component.ts')
-rw-r--r-- | client/src/app/+search/search.component.ts | 36 |
1 files changed, 27 insertions, 9 deletions
diff --git a/client/src/app/+search/search.component.ts b/client/src/app/+search/search.component.ts index 1ed54937b..70116fab3 100644 --- a/client/src/app/+search/search.component.ts +++ b/client/src/app/+search/search.component.ts | |||
@@ -5,7 +5,7 @@ import { AuthService, ComponentPagination, HooksService, Notifier, ServerService | |||
5 | import { immutableAssign } from '@app/helpers' | 5 | import { immutableAssign } from '@app/helpers' |
6 | import { Video, VideoChannel } from '@app/shared/shared-main' | 6 | import { Video, VideoChannel } from '@app/shared/shared-main' |
7 | import { AdvancedSearch, SearchService } from '@app/shared/shared-search' | 7 | import { AdvancedSearch, SearchService } from '@app/shared/shared-search' |
8 | import { MiniatureDisplayOptions } from '@app/shared/shared-video-miniature' | 8 | import { MiniatureDisplayOptions, VideoLinkType } from '@app/shared/shared-video-miniature' |
9 | import { MetaService } from '@ngx-meta/core' | 9 | import { MetaService } from '@ngx-meta/core' |
10 | import { I18n } from '@ngx-translate/i18n-polyfill' | 10 | import { I18n } from '@ngx-translate/i18n-polyfill' |
11 | import { SearchTargetType, ServerConfig } from '@shared/models' | 11 | import { SearchTargetType, ServerConfig } from '@shared/models' |
@@ -119,6 +119,25 @@ export class SearchComponent implements OnInit, OnDestroy { | |||
119 | return this.authService.isLoggedIn() | 119 | return this.authService.isLoggedIn() |
120 | } | 120 | } |
121 | 121 | ||
122 | getVideoLinkType (): VideoLinkType { | ||
123 | if (this.advancedSearch.searchTarget === 'search-index') { | ||
124 | const remoteUriConfig = this.serverConfig.search.remoteUri | ||
125 | |||
126 | // Redirect on the external instance if not allowed to fetch remote data | ||
127 | if ((!this.isUserLoggedIn() && !remoteUriConfig.anonymous) || !remoteUriConfig.users) { | ||
128 | return 'external' | ||
129 | } | ||
130 | |||
131 | return 'lazy-load' | ||
132 | } | ||
133 | |||
134 | return 'internal' | ||
135 | } | ||
136 | |||
137 | isExternalChannelUrl () { | ||
138 | return this.getVideoLinkType() === 'external' | ||
139 | } | ||
140 | |||
122 | search () { | 141 | search () { |
123 | forkJoin([ | 142 | forkJoin([ |
124 | this.getVideosObs(), | 143 | this.getVideosObs(), |
@@ -184,17 +203,16 @@ export class SearchComponent implements OnInit, OnDestroy { | |||
184 | } | 203 | } |
185 | 204 | ||
186 | getChannelUrl (channel: VideoChannel) { | 205 | getChannelUrl (channel: VideoChannel) { |
187 | if (this.advancedSearch.searchTarget === 'search-index' && channel.url) { | 206 | // Same algorithm than videos |
188 | const remoteUriConfig = this.serverConfig.search.remoteUri | 207 | if (this.getVideoLinkType() === 'external') { |
189 | 208 | return channel.url | |
190 | // Redirect on the external instance if not allowed to fetch remote data | 209 | } |
191 | const externalRedirect = (!this.authService.isLoggedIn() && !remoteUriConfig.anonymous) || !remoteUriConfig.users | ||
192 | const fromPath = window.location.pathname + window.location.search | ||
193 | 210 | ||
194 | return [ '/search/lazy-load-channel', { url: channel.url, externalRedirect, fromPath } ] | 211 | if (this.getVideoLinkType() === 'internal') { |
212 | return [ '/video-channels', channel.nameWithHost ] | ||
195 | } | 213 | } |
196 | 214 | ||
197 | return [ '/video-channels', channel.nameWithHost ] | 215 | return [ '/search/lazy-load-channel', { url: channel.url } ] |
198 | } | 216 | } |
199 | 217 | ||
200 | hideActions () { | 218 | hideActions () { |