diff options
| author | Patrick Barron <barronpm@gmail.com> | 2020-07-11 14:11:55 -0400 |
|---|---|---|
| committer | Patrick Barron <barronpm@gmail.com> | 2020-07-17 16:11:54 -0400 |
| commit | f3263c7d8ef9aa284c52fa6bd68adc1ed7c435da (patch) | |
| tree | 0c3e3ab8d48de5405c6340af48ad99fba5120652 /MediaBrowser.Api/DisplayPreferencesService.cs | |
| parent | 3c7eb6b324ba9cf20244f136ee743bef91d4a8f3 (diff) | |
Remove limit of 7 home sections
Diffstat (limited to 'MediaBrowser.Api/DisplayPreferencesService.cs')
| -rw-r--r-- | MediaBrowser.Api/DisplayPreferencesService.cs | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/MediaBrowser.Api/DisplayPreferencesService.cs b/MediaBrowser.Api/DisplayPreferencesService.cs index e5dd03807..969bf564c 100644 --- a/MediaBrowser.Api/DisplayPreferencesService.cs +++ b/MediaBrowser.Api/DisplayPreferencesService.cs @@ -1,10 +1,12 @@ using System; +using System.Linq; using Jellyfin.Data.Entities; using Jellyfin.Data.Enums; using MediaBrowser.Controller; using MediaBrowser.Controller.Configuration; using MediaBrowser.Controller.Net; using MediaBrowser.Model.Entities; +using MediaBrowser.Model.Querying; using MediaBrowser.Model.Services; using Microsoft.Extensions.Logging; @@ -135,16 +137,19 @@ namespace MediaBrowser.Api prefs.ScrollDirection = request.ScrollDirection; prefs.HomeSections.Clear(); - for (int i = 0; i < 7; i++) + foreach (var key in request.CustomPrefs.Keys.Where(key => key.StartsWith("homesection"))) { - if (request.CustomPrefs.TryGetValue("homesection" + i, out var homeSection)) + var order = int.Parse(key.Substring("homesection".Length)); + if (!Enum.TryParse<HomeSectionType>(request.CustomPrefs[key], true, out var type)) { - prefs.HomeSections.Add(new HomeSection - { - Order = i, - Type = Enum.TryParse<HomeSectionType>(homeSection, true, out var type) ? type : defaults[i] - }); + type = order < 7 ? defaults[order] : HomeSectionType.None; } + + prefs.HomeSections.Add(new HomeSection + { + Order = order, + Type = type + }); } _displayPreferencesManager.SaveChanges(prefs); |
