aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/core
diff options
context:
space:
mode:
authorRigel Kent <sendmemail@rigelk.eu>2021-01-27 17:15:21 +0100
committerChocobozzz <chocobozzz@cpy.re>2021-01-28 15:55:34 +0100
commitba5d4a849c7d7ba05f093480ae12286c4af61556 (patch)
tree704a80b96d3b437ad12feacaaaf58a96b97282a1 /client/src/app/core
parent3da68f0a781ebd893521e2e6fa200280c92ae815 (diff)
downloadPeerTube-ba5d4a849c7d7ba05f093480ae12286c4af61556.tar.gz
PeerTube-ba5d4a849c7d7ba05f093480ae12286c4af61556.tar.zst
PeerTube-ba5d4a849c7d7ba05f093480ae12286c4af61556.zip
move from trending routes to alg param
Diffstat (limited to 'client/src/app/core')
-rw-r--r--client/src/app/core/core.module.ts3
-rw-r--r--client/src/app/core/routing/index.ts1
-rw-r--r--client/src/app/core/routing/redirect.service.ts34
-rw-r--r--client/src/app/core/routing/trending-guard.service.ts14
-rw-r--r--client/src/app/core/server/server.service.ts12
5 files changed, 17 insertions, 47 deletions
diff --git a/client/src/app/core/core.module.ts b/client/src/app/core/core.module.ts
index 32dfc8f36..2392a234c 100644
--- a/client/src/app/core/core.module.ts
+++ b/client/src/app/core/core.module.ts
@@ -15,7 +15,7 @@ import { throwIfAlreadyLoaded } from './module-import-guard'
15import { Notifier } from './notification' 15import { Notifier } from './notification'
16import { HtmlRendererService, LinkifierService, MarkdownService } from './renderer' 16import { HtmlRendererService, LinkifierService, MarkdownService } from './renderer'
17import { RestExtractor, RestService } from './rest' 17import { RestExtractor, RestService } from './rest'
18import { LoginGuard, RedirectService, UserRightGuard, UnloggedGuard, TrendingGuard } from './routing' 18import { LoginGuard, RedirectService, UserRightGuard, UnloggedGuard } from './routing'
19import { CanDeactivateGuard } from './routing/can-deactivate-guard.service' 19import { CanDeactivateGuard } from './routing/can-deactivate-guard.service'
20import { ServerConfigResolver } from './routing/server-config-resolver.service' 20import { ServerConfigResolver } from './routing/server-config-resolver.service'
21import { ScopedTokensService } from './scoped-tokens' 21import { ScopedTokensService } from './scoped-tokens'
@@ -56,7 +56,6 @@ import { LocalStorageService, ScreenService, SessionStorageService } from './wra
56 LoginGuard, 56 LoginGuard,
57 UserRightGuard, 57 UserRightGuard,
58 UnloggedGuard, 58 UnloggedGuard,
59 TrendingGuard,
60 59
61 PluginService, 60 PluginService,
62 HooksService, 61 HooksService,
diff --git a/client/src/app/core/routing/index.ts b/client/src/app/core/routing/index.ts
index b3985d870..239c27caf 100644
--- a/client/src/app/core/routing/index.ts
+++ b/client/src/app/core/routing/index.ts
@@ -8,4 +8,3 @@ export * from './redirect.service'
8export * from './server-config-resolver.service' 8export * from './server-config-resolver.service'
9export * from './unlogged-guard.service' 9export * from './unlogged-guard.service'
10export * from './user-right-guard.service' 10export * from './user-right-guard.service'
11export * from './trending-guard.service'
diff --git a/client/src/app/core/routing/redirect.service.ts b/client/src/app/core/routing/redirect.service.ts
index 76e28e461..6d26fb504 100644
--- a/client/src/app/core/routing/redirect.service.ts
+++ b/client/src/app/core/routing/redirect.service.ts
@@ -7,14 +7,13 @@ export class RedirectService {
7 // Default route could change according to the instance configuration 7 // Default route could change according to the instance configuration
8 static INIT_DEFAULT_ROUTE = '/videos/trending' 8 static INIT_DEFAULT_ROUTE = '/videos/trending'
9 static DEFAULT_ROUTE = RedirectService.INIT_DEFAULT_ROUTE 9 static DEFAULT_ROUTE = RedirectService.INIT_DEFAULT_ROUTE
10 static INIT_DEFAULT_TRENDING_ROUTE = '/videos/most-viewed' 10 static INIT_DEFAULT_TRENDING_ALGORITHM = 'most-viewed'
11 static DEFAULT_TRENDING_ROUTE = RedirectService.INIT_DEFAULT_TRENDING_ROUTE 11 static DEFAULT_TRENDING_ALGORITHM = RedirectService.INIT_DEFAULT_TRENDING_ALGORITHM
12 12
13 private previousUrl: string 13 private previousUrl: string
14 private currentUrl: string 14 private currentUrl: string
15 15
16 private redirectingToHomepage = false 16 private redirectingToHomepage = false
17 private redirectingToTrending = false
18 17
19 constructor ( 18 constructor (
20 private router: Router, 19 private router: Router,
@@ -22,27 +21,25 @@ export class RedirectService {
22 ) { 21 ) {
23 // The config is first loaded from the cache so try to get the default route 22 // The config is first loaded from the cache so try to get the default route
24 const tmpConfig = this.serverService.getTmpConfig() 23 const tmpConfig = this.serverService.getTmpConfig()
25 if (tmpConfig && tmpConfig.instance) { 24 if (tmpConfig?.instance?.defaultClientRoute) {
26 if (tmpConfig.instance.defaultClientRoute) { 25 RedirectService.DEFAULT_ROUTE = tmpConfig.instance.defaultClientRoute
27 RedirectService.DEFAULT_ROUTE = tmpConfig.instance.defaultClientRoute 26 }
28 } 27 if (tmpConfig?.trending?.videos?.algorithms?.default) {
29 if (tmpConfig.instance.defaultTrendingRoute) { 28 RedirectService.DEFAULT_TRENDING_ALGORITHM = tmpConfig.trending.videos.algorithms.default
30 RedirectService.DEFAULT_TRENDING_ROUTE = tmpConfig.instance.defaultTrendingRoute
31 }
32 } 29 }
33 30
34 // Load default route 31 // Load default route
35 this.serverService.getConfig() 32 this.serverService.getConfig()
36 .subscribe(config => { 33 .subscribe(config => {
37 const defaultRouteConfig = config.instance.defaultClientRoute 34 const defaultRouteConfig = config.instance.defaultClientRoute
38 const defaultTrendingConfig = config.instance.defaultTrendingRoute 35 const defaultTrendingConfig = config.trending.videos.algorithms.default
39 36
40 if (defaultRouteConfig) { 37 if (defaultRouteConfig) {
41 RedirectService.DEFAULT_ROUTE = defaultRouteConfig 38 RedirectService.DEFAULT_ROUTE = defaultRouteConfig
42 } 39 }
43 40
44 if (defaultTrendingConfig) { 41 if (defaultTrendingConfig) {
45 RedirectService.DEFAULT_TRENDING_ROUTE = defaultTrendingConfig 42 RedirectService.DEFAULT_TRENDING_ALGORITHM = defaultTrendingConfig
46 } 43 }
47 }) 44 })
48 45
@@ -70,15 +67,6 @@ export class RedirectService {
70 return this.redirectToHomepage() 67 return this.redirectToHomepage()
71 } 68 }
72 69
73 redirectToTrending () {
74 if (this.redirectingToTrending) return
75
76 this.redirectingToTrending = true
77
78 this.router.navigate([ RedirectService.DEFAULT_TRENDING_ROUTE ])
79 .then(() => this.redirectingToTrending = false)
80 }
81
82 redirectToHomepage (skipLocationChange = false) { 70 redirectToHomepage (skipLocationChange = false) {
83 if (this.redirectingToHomepage) return 71 if (this.redirectingToHomepage) return
84 72
@@ -86,7 +74,7 @@ export class RedirectService {
86 74
87 console.log('Redirecting to %s...', RedirectService.DEFAULT_ROUTE) 75 console.log('Redirecting to %s...', RedirectService.DEFAULT_ROUTE)
88 76
89 this.router.navigate([ RedirectService.DEFAULT_ROUTE ], { skipLocationChange }) 77 this.router.navigateByUrl(RedirectService.DEFAULT_ROUTE, { skipLocationChange })
90 .then(() => this.redirectingToHomepage = false) 78 .then(() => this.redirectingToHomepage = false)
91 .catch(() => { 79 .catch(() => {
92 this.redirectingToHomepage = false 80 this.redirectingToHomepage = false
@@ -98,7 +86,7 @@ export class RedirectService {
98 ) 86 )
99 87
100 RedirectService.DEFAULT_ROUTE = RedirectService.INIT_DEFAULT_ROUTE 88 RedirectService.DEFAULT_ROUTE = RedirectService.INIT_DEFAULT_ROUTE
101 return this.router.navigate([ RedirectService.DEFAULT_ROUTE ], { skipLocationChange }) 89 return this.router.navigateByUrl(RedirectService.DEFAULT_ROUTE, { skipLocationChange })
102 }) 90 })
103 91
104 } 92 }
diff --git a/client/src/app/core/routing/trending-guard.service.ts b/client/src/app/core/routing/trending-guard.service.ts
deleted file mode 100644
index 7db7fe994..000000000
--- a/client/src/app/core/routing/trending-guard.service.ts
+++ /dev/null
@@ -1,14 +0,0 @@
1import { Injectable } from '@angular/core'
2import { ActivatedRouteSnapshot, CanActivate, RouterStateSnapshot } from '@angular/router'
3import { RedirectService } from './redirect.service'
4
5@Injectable()
6export class TrendingGuard implements CanActivate {
7
8 constructor (private redirectService: RedirectService) {}
9
10 canActivate (route: ActivatedRouteSnapshot, state: RouterStateSnapshot) {
11 this.redirectService.redirectToTrending()
12 return false
13 }
14}
diff --git a/client/src/app/core/server/server.service.ts b/client/src/app/core/server/server.service.ts
index 5f13190b4..a38883eee 100644
--- a/client/src/app/core/server/server.service.ts
+++ b/client/src/app/core/server/server.service.ts
@@ -39,12 +39,6 @@ export class ServerService {
39 isNSFW: false, 39 isNSFW: false,
40 defaultNSFWPolicy: 'do_not_list' as 'do_not_list', 40 defaultNSFWPolicy: 'do_not_list' as 'do_not_list',
41 defaultClientRoute: '', 41 defaultClientRoute: '',
42 defaultTrendingRoute: '',
43 pages: {
44 hot: {
45 enabled: true
46 }
47 },
48 customizations: { 42 customizations: {
49 javascript: '', 43 javascript: '',
50 css: '' 44 css: ''
@@ -131,7 +125,11 @@ export class ServerService {
131 }, 125 },
132 trending: { 126 trending: {
133 videos: { 127 videos: {
134 intervalDays: 0 128 intervalDays: 0,
129 algorithms: {
130 enabled: [ 'hot', 'most-viewed', 'most-liked' ],
131 default: 'most-viewed'
132 }
135 } 133 }
136 }, 134 },
137 autoBlacklist: { 135 autoBlacklist: {