ActivityPub-federated video streaming platform using P2P directly in your web browser
Fix default trending algorithm in admin config
Chocobozzz15825ef18d3b
diff --git a/client/src/app/+admin/config/edit-custom-config/edit-basic-configuration.component.html b/client/src/app/+admin/config/edit-custom-config/edit-basic-configuration.component.htmlindex 22ae0852cb..2a9f9d69d1 100644--- a/client/src/app/+admin/config/edit-custom-config/edit-basic-configuration.component.html+++ b/client/src/app/+admin/config/edit-custom-config/edit-basic-configuration.component.html@@ -44,9 +44,6 @@<div class="peertube-select-container"><select id="trendingVideosAlgorithmsDefault" formControlName="default" class="form-control">- <option i18n value="publishedAt">Recently added videos</option>- <option i18n value="originallyPublishedAt">Original publication date</option>- <option i18n value="name">Name</option><option i18n value="hot">Hot videos</option><option i18n value="most-viewed">Recent views</option><option i18n value="most-liked">Most liked videos</option>diff --git a/client/src/app/+videos/video-list/videos-list-common-page.component.ts b/client/src/app/+videos/video-list/videos-list-common-page.component.tsindex bafe30fd78..c8fa8ef302 100644--- a/client/src/app/+videos/video-list/videos-list-common-page.component.ts+++ b/client/src/app/+videos/video-list/videos-list-common-page.component.ts@@ -177,9 +177,6 @@ export class VideosListCommonPageComponent implements OnInit, OnDestroy, Disablecase 'best':return '-hot'- case 'name':- return 'name'-default:return '-' + algorithm as VideoSortField}diff --git a/client/src/app/app.module.ts b/client/src/app/app.module.tsindex bb20c2d83f..7e4fac730f 100644--- a/client/src/app/app.module.ts+++ b/client/src/app/app.module.ts@@ -8,7 +8,7 @@ import { ServiceWorkerModule } from '@angular/service-worker'import localeOc from '@app/helpers/locales/oc'import { AppRoutingModule } from './app-routing.module'import { AppComponent } from './app.component'-import { CoreModule, PluginService, ServerService } from './core'+import { CoreModule, PluginService, RedirectService, ServerService } from './core'import { EmptyComponent } from './empty.component'import { HeaderComponent, SearchTypeaheadComponent, SuggestionComponent } from './header'import { HighlightPipe } from './header/highlight.pipe'@@ -28,13 +28,17 @@ import { SharedUserInterfaceSettingsModule } from './shared/shared-user-settingsregisterLocaleData(localeOc, 'oc')-export function loadConfigFactory (server: ServerService, pluginService: PluginService) {+export function loadConfigFactory (server: ServerService, pluginService: PluginService, redirectService: RedirectService) {+ const initializeServices = () => {+ redirectService.init()+ pluginService.initializePlugins()+ }+return () => {const result = server.loadHTMLConfig()+ if (result) return result.pipe(tap(() => initializeServices()))- if (result) return result.pipe(tap(() => pluginService.initializePlugins()))-- return pluginService.initializePlugins()+ initializeServices()}}@@ -84,7 +88,7 @@ export function loadConfigFactory (server: ServerService, pluginService: PluginS{provide: APP_INITIALIZER,useFactory: loadConfigFactory,- deps: [ ServerService, PluginService ],+ deps: [ ServerService, PluginService, RedirectService ],multi: true}]diff --git a/client/src/app/core/routing/redirect.service.ts b/client/src/app/core/routing/redirect.service.tsindex e239c62103..1120e61657 100644--- a/client/src/app/core/routing/redirect.service.ts+++ b/client/src/app/core/routing/redirect.service.ts@@ -31,12 +31,15 @@ export class RedirectService {private serverService: ServerService,private storage: SessionStorageService) {- // The config is first loaded from the cache so try to get the default route++ }++ init () {const config = this.serverService.getHTMLConfig()- if (config?.instance?.defaultClientRoute) {+ if (config.instance.defaultClientRoute) {this.defaultRoute = config.instance.defaultClientRoute}- if (config?.trending?.videos?.algorithms?.default) {+ if (config.trending.videos.algorithms.default) {this.defaultTrendingAlgorithm = config.trending.videos.algorithms.default}@@ -47,7 +50,7 @@ export class RedirectService {// Track previous urlthis.currentUrl = this.router.url- router.events.subscribe(event => {+ this.router.events.subscribe(event => {if (event instanceof NavigationEnd || event instanceof NavigationCancel) {if ([ '/401', '/404' ].includes(event.url)) returndiff --git a/client/src/app/core/server/server.service.ts b/client/src/app/core/server/server.service.tsindex 9db455cb86..0829d87d5c 100644--- a/client/src/app/core/server/server.service.ts+++ b/client/src/app/core/server/server.service.ts@@ -40,7 +40,7 @@ export class ServerService {loadHTMLConfig () {try {- return this.loadHTMLConfigLocally()+ this.loadHTMLConfigLocally()} catch (err) {// Expected in dev mode since we can't inject the config in the HTMLif (environment.production !== false) {diff --git a/config/default.yaml b/config/default.yamlindex 37059e9e01..bb4a823fad 100644--- a/config/default.yaml+++ b/config/default.yaml@@ -236,12 +236,14 @@ open_telemetry:trending:videos:- interval_days: 7 # Compute trending videos for the last x days+ interval_days: 7 # Compute trending videos for the last x days for 'most-viewed' algorithm+algorithms:enabled:- - 'hot' # adaptation of Reddit's 'Hot' algorithm- - 'most-viewed' # default, used initially by PeerTube as the trending page- - 'most-liked'+ - 'hot' # Adaptation of Reddit's 'Hot' algorithm+ - 'most-viewed' # Number of views in the last x days+ - 'most-liked' # Global views since the upload of the video+default: 'most-viewed'# Cache remote videos on your server, to help other instances to broadcast the videodiff --git a/config/production.yaml.example b/config/production.yaml.exampleindex 906fb7e1f1..f1ebf90950 100644--- a/config/production.yaml.example+++ b/config/production.yaml.example@@ -234,12 +234,14 @@ open_telemetry:trending:videos:- interval_days: 7 # Compute trending videos for the last x days+ interval_days: 7 # Compute trending videos for the last x days for 'most-viewed' algorithm+algorithms:enabled:- - 'hot' # adaptation of Reddit's 'Hot' algorithm- - 'most-viewed' # default, used initially by PeerTube as the trending page- - 'most-liked'+ - 'hot' # Adaptation of Reddit's 'Hot' algorithm+ - 'most-viewed' # Number of views in the last x days+ - 'most-liked' # Global views since the upload of the video+default: 'most-viewed'# Cache remote videos on your server, to help other instances to broadcast the video