🎧 Your Personal Streaming Service
Go airsonicmadsonicmedia-servermusicmusic-servernavidromeopensubsonicraspberry-piself-hostedstreamerstreaming-apistreaming-audiosubsonicsubsonic-server
Add option to change max playlists shown in UI's sidebar, `MaxSidebarPlaylists`. Fix #2077
Deluan128b626ec933
diff --git a/conf/configuration.go b/conf/configuration.goindex c7a0f4ca3..f2dd406dd 100644--- a/conf/configuration.go+++ b/conf/configuration.go@@ -29,6 +29,8 @@ type configOptions struct {SessionTimeout time.DurationBaseURL stringUILoginBackgroundURL string+ UIWelcomeMessage string+ MaxSidebarPlaylists intEnableTranscodingConfig boolEnableDownloads boolEnableExternalServices bool@@ -47,7 +49,6 @@ type configOptions struct {ProbeCommand stringCoverArtPriority stringCoverJpegQuality int- UIWelcomeMessage stringEnableGravatar boolEnableFavourites boolEnableStarRating bool@@ -224,6 +225,8 @@ func init() {viper.SetDefault("scanschedule", "@every 1m")viper.SetDefault("baseurl", "")viper.SetDefault("uiloginbackgroundurl", consts.DefaultUILoginBackgroundURL)+ viper.SetDefault("uiwelcomemessage", "")+ viper.SetDefault("maxsidebarplaylists", consts.DefaultMaxSidebarPlaylists)viper.SetDefault("enabletranscodingconfig", false)viper.SetDefault("transcodingcachesize", "100MB")viper.SetDefault("imagecachesize", "100MB")@@ -242,7 +245,6 @@ func init() {viper.SetDefault("probecommand", "ffmpeg %s -f ffmetadata")viper.SetDefault("coverartpriority", "cover.*, folder.*, front.*, embedded, external")viper.SetDefault("coverjpegquality", 75)- viper.SetDefault("uiwelcomemessage", "")viper.SetDefault("enablegravatar", false)viper.SetDefault("enablefavourites", true)viper.SetDefault("enablestarrating", true)diff --git a/consts/consts.go b/consts/consts.goindex f1483f474..16400f68d 100644--- a/consts/consts.go+++ b/consts/consts.go@@ -43,6 +43,7 @@ const (// DefaultUILoginBackgroundOffline Background image used in case external integrations are disabledDefaultUILoginBackgroundOffline = "iVBORw0KGgoAAAANSUhEUgAAAMgAAADICAIAAAAiOjnJAAAABGdBTUEAALGPC/xhBQAAAiJJREFUeF7t0IEAAAAAw6D5Ux/khVBhwIABAwYMGDBgwIABAwYMGDBgwIABAwYMGDBgwIABAwYMGDBgwIABAwYMGDBgwIABAwYMGDBgwIABAwYMGDBgwIABAwYMGDBgwIABAwYMGDBgwIABAwYMGDBgwIABAwYMGDBgwIABAwYMGDBgwIABAwYMGDBgwIABAwYMGDBgwIABAwYMGDBgwIABAwYMGDBgwIABAwYMGDBgwIABAwYMGDBgwIABAwYMGDBgwIABAwYMGDBgwIABAwYMGDBgwIABAwYMGDBgwIABAwYMGDBgwIABAwYMGDBgwIABAwYMGDBgwIABAwYMGDBgwIABAwYMGDBgwIABAwYMGDBgwIABAwYMGDBgwIABAwYMGDBgwIABAwYMGDBgwIABAwYMGDBgwIABAwYMGDBgwIABAwYMGDBgwIABAwYMGDBgwIABAwYMGDBgwIABAwYMGDBgwIABAwYMGDBgwIABAwYMGDBgwIABAwYMGDBgwIABAwYMGDBgwIABAwYMGDBgwIABAwYMGDBgwIABAwYMGDBgwIABAwYMGDBgwIABAwYMGDBgwIABAwYMGDBgwIABAwYMGDBgwIABAwYMGDBgwIABAwYMGDBgwIABAwYMGDBgwIABAwYMGDBgwIABAwYMGDBgwIABAwYMGDBgwIABAwYMGDBgwIABAwYMGDBgwIABAwYMGDBgwIABAwYMGDDwMDDVlwABBWcSrQAAAABJRU5ErkJggg=="DefaultUILoginBackgroundURLOffline = "data:image/png;base64," + DefaultUILoginBackgroundOffline+ DefaultMaxSidebarPlaylists = 100RequestThrottleBacklogLimit = 100RequestThrottleBacklogTimeout = time.Minutediff --git a/server/serve_index.go b/server/serve_index.goindex 196a2de3c..263d651f3 100644--- a/server/serve_index.go+++ b/server/serve_index.go@@ -44,6 +44,7 @@ func serveIndex(ds model.DataStore, fs fs.FS, shareInfo *model.Share) http.Handl"baseURL": utils.SanitizeText(strings.TrimSuffix(conf.Server.BaseURL, "/")),"loginBackgroundURL": utils.SanitizeText(conf.Server.UILoginBackgroundURL),"welcomeMessage": utils.SanitizeText(conf.Server.UIWelcomeMessage),+ "maxSidebarPlaylists": conf.Server.MaxSidebarPlaylists,"enableTranscodingConfig": conf.Server.EnableTranscodingConfig,"enableDownloads": conf.Server.EnableDownloads,"enableFavourites": conf.Server.EnableFavourites,diff --git a/server/serve_index_test.go b/server/serve_index_test.goindex 6908be9fb..5810992f6 100644--- a/server/serve_index_test.go+++ b/server/serve_index_test.go@@ -94,6 +94,17 @@ var _ = Describe("serveIndex", func() {Expect(config).To(HaveKeyWithValue("welcomeMessage", "Hello"))})+ It("sets the maxSidebarPlaylists", func() {+ conf.Server.MaxSidebarPlaylists = 42+ r := httptest.NewRequest("GET", "/index.html", nil)+ w := httptest.NewRecorder()++ serveIndex(ds, fs, nil)(w, r)++ config := extractAppConfig(w.Body.String())+ Expect(config).To(HaveKeyWithValue("maxSidebarPlaylists", float64(42)))+ })+It("sets the enableTranscodingConfig", func() {conf.Server.EnableTranscodingConfig = truer := httptest.NewRequest("GET", "/index.html", nil)diff --git a/ui/src/config.js b/ui/src/config.jsindex da24ba3fc..abf409868 100644--- a/ui/src/config.js+++ b/ui/src/config.js@@ -8,6 +8,7 @@ const defaultConfig = {variousArtistsId: '03b645ef2100dfc42fa9785ea3102295', // See consts.VariousArtistsID in consts.go// Login backgrounds from https://unsplash.com/collections/1065384/music-wallpapersloginBackgroundURL: 'https://source.unsplash.com/collection/1065384/1600x900',+ maxSidebarPlaylists: 100,enableTranscodingConfig: true,enableDownloads: true,enableFavourites: true,diff --git a/ui/src/consts.js b/ui/src/consts.jsindex cf735a28f..20c8bac2b 100644--- a/ui/src/consts.js+++ b/ui/src/consts.js@@ -19,8 +19,6 @@ DraggableTypes.ALL.push(DraggableTypes.ARTIST)-export const MAX_SIDEBAR_PLAYLISTS = 100-export const DEFAULT_SHARE_BITRATE = 128export const BITRATE_CHOICES = [diff --git a/ui/src/layout/PlaylistsSubMenu.js b/ui/src/layout/PlaylistsSubMenu.jsindex 0e9646a11..e16aa7e18 100644--- a/ui/src/layout/PlaylistsSubMenu.js+++ b/ui/src/layout/PlaylistsSubMenu.js@@ -13,7 +13,8 @@ import { BiCog } from 'react-icons/bi'import { useDrop } from 'react-dnd'import SubMenu from './SubMenu'import { canChangeTracks } from '../common'-import { DraggableTypes, MAX_SIDEBAR_PLAYLISTS } from '../consts'+import { DraggableTypes } from '../consts'+import config from '../config'const PlaylistMenuItemLink = ({ pls, sidebarIsOpen }) => {const dataProvider = useDataProvider()@@ -56,7 +57,7 @@ const PlaylistsSubMenu = ({ state, setState, sidebarIsOpen, dense }) => {payload: {pagination: {page: 0,- perPage: MAX_SIDEBAR_PLAYLISTS,+ perPage: config.maxSidebarPlaylists,},sort: { field: 'name' },},