fix landing screen options
This commit is contained in:
parent
9e601ba731
commit
0332b72502
|
@ -12,6 +12,7 @@ using MediaBrowser.Model.Entities;
|
||||||
using Microsoft.AspNetCore.Authorization;
|
using Microsoft.AspNetCore.Authorization;
|
||||||
using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Http;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
|
||||||
namespace Jellyfin.Api.Controllers
|
namespace Jellyfin.Api.Controllers
|
||||||
{
|
{
|
||||||
|
@ -22,14 +23,17 @@ namespace Jellyfin.Api.Controllers
|
||||||
public class DisplayPreferencesController : BaseJellyfinApiController
|
public class DisplayPreferencesController : BaseJellyfinApiController
|
||||||
{
|
{
|
||||||
private readonly IDisplayPreferencesManager _displayPreferencesManager;
|
private readonly IDisplayPreferencesManager _displayPreferencesManager;
|
||||||
|
private readonly ILogger<DisplayPreferencesController> _logger;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes a new instance of the <see cref="DisplayPreferencesController"/> class.
|
/// Initializes a new instance of the <see cref="DisplayPreferencesController"/> class.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="displayPreferencesManager">Instance of <see cref="IDisplayPreferencesManager"/> interface.</param>
|
/// <param name="displayPreferencesManager">Instance of <see cref="IDisplayPreferencesManager"/> interface.</param>
|
||||||
public DisplayPreferencesController(IDisplayPreferencesManager displayPreferencesManager)
|
/// <param name="logger">Instance of <see cref="ILogger{DisplayPreferencesController}"/> interface.</param>
|
||||||
|
public DisplayPreferencesController(IDisplayPreferencesManager displayPreferencesManager, ILogger<DisplayPreferencesController> logger)
|
||||||
{
|
{
|
||||||
_displayPreferencesManager = displayPreferencesManager;
|
_displayPreferencesManager = displayPreferencesManager;
|
||||||
|
_logger = logger;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -61,7 +65,6 @@ namespace Jellyfin.Api.Controllers
|
||||||
{
|
{
|
||||||
Client = displayPreferences.Client,
|
Client = displayPreferences.Client,
|
||||||
Id = displayPreferences.ItemId.ToString(),
|
Id = displayPreferences.ItemId.ToString(),
|
||||||
ViewType = itemPreferences.ViewType.ToString(),
|
|
||||||
SortBy = itemPreferences.SortBy,
|
SortBy = itemPreferences.SortBy,
|
||||||
SortOrder = itemPreferences.SortOrder,
|
SortOrder = itemPreferences.SortOrder,
|
||||||
IndexBy = displayPreferences.IndexBy?.ToString(),
|
IndexBy = displayPreferences.IndexBy?.ToString(),
|
||||||
|
@ -77,11 +80,6 @@ namespace Jellyfin.Api.Controllers
|
||||||
dto.CustomPrefs["homesection" + homeSection.Order] = homeSection.Type.ToString().ToLowerInvariant();
|
dto.CustomPrefs["homesection" + homeSection.Order] = homeSection.Type.ToString().ToLowerInvariant();
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (var itemDisplayPreferences in _displayPreferencesManager.ListItemDisplayPreferences(displayPreferences.UserId, displayPreferences.Client))
|
|
||||||
{
|
|
||||||
dto.CustomPrefs["landing-" + itemDisplayPreferences.ItemId] = itemDisplayPreferences.ViewType.ToString().ToLowerInvariant();
|
|
||||||
}
|
|
||||||
|
|
||||||
dto.CustomPrefs["chromecastVersion"] = displayPreferences.ChromecastVersion.ToString().ToLowerInvariant();
|
dto.CustomPrefs["chromecastVersion"] = displayPreferences.ChromecastVersion.ToString().ToLowerInvariant();
|
||||||
dto.CustomPrefs["skipForwardLength"] = displayPreferences.SkipForwardLength.ToString(CultureInfo.InvariantCulture);
|
dto.CustomPrefs["skipForwardLength"] = displayPreferences.SkipForwardLength.ToString(CultureInfo.InvariantCulture);
|
||||||
dto.CustomPrefs["skipBackLength"] = displayPreferences.SkipBackwardLength.ToString(CultureInfo.InvariantCulture);
|
dto.CustomPrefs["skipBackLength"] = displayPreferences.SkipBackwardLength.ToString(CultureInfo.InvariantCulture);
|
||||||
|
@ -189,10 +187,9 @@ namespace Jellyfin.Api.Controllers
|
||||||
|
|
||||||
foreach (var key in displayPreferences.CustomPrefs.Keys.Where(key => key.StartsWith("landing-", StringComparison.OrdinalIgnoreCase)))
|
foreach (var key in displayPreferences.CustomPrefs.Keys.Where(key => key.StartsWith("landing-", StringComparison.OrdinalIgnoreCase)))
|
||||||
{
|
{
|
||||||
if (Guid.TryParse(key.AsSpan().Slice("landing-".Length), out var preferenceId))
|
if (!Enum.TryParse<ViewType>(displayPreferences.CustomPrefs[key], true, out var type))
|
||||||
{
|
{
|
||||||
var itemPreferences = _displayPreferencesManager.GetItemDisplayPreferences(existingDisplayPreferences.UserId, preferenceId, existingDisplayPreferences.Client);
|
_logger.LogError("Invaild ViewType: {LandingScreenOption}", displayPreferences.CustomPrefs[key]);
|
||||||
itemPreferences.ViewType = Enum.Parse<ViewType>(displayPreferences.ViewType);
|
|
||||||
displayPreferences.CustomPrefs.Remove(key);
|
displayPreferences.CustomPrefs.Remove(key);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -204,11 +201,6 @@ namespace Jellyfin.Api.Controllers
|
||||||
itemPrefs.RememberSorting = displayPreferences.RememberSorting;
|
itemPrefs.RememberSorting = displayPreferences.RememberSorting;
|
||||||
itemPrefs.ItemId = itemId;
|
itemPrefs.ItemId = itemId;
|
||||||
|
|
||||||
if (Enum.TryParse<ViewType>(displayPreferences.ViewType, true, out var viewType))
|
|
||||||
{
|
|
||||||
itemPrefs.ViewType = viewType;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Set all remaining custom preferences.
|
// Set all remaining custom preferences.
|
||||||
_displayPreferencesManager.SetCustomItemDisplayPreferences(userId, itemId, existingDisplayPreferences.Client, displayPreferences.CustomPrefs);
|
_displayPreferencesManager.SetCustomItemDisplayPreferences(userId, itemId, existingDisplayPreferences.Client, displayPreferences.CustomPrefs);
|
||||||
_displayPreferencesManager.SaveChanges();
|
_displayPreferencesManager.SaveChanges();
|
||||||
|
|
|
@ -23,7 +23,6 @@ namespace Jellyfin.Data.Entities
|
||||||
Client = client;
|
Client = client;
|
||||||
|
|
||||||
SortBy = "SortName";
|
SortBy = "SortName";
|
||||||
ViewType = ViewType.Poster;
|
|
||||||
SortOrder = SortOrder.Ascending;
|
SortOrder = SortOrder.Ascending;
|
||||||
RememberSorting = false;
|
RememberSorting = false;
|
||||||
RememberIndexing = false;
|
RememberIndexing = false;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
namespace Jellyfin.Data.Enums
|
namespace Jellyfin.Data.Enums
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// An enum representing the type of view for a library or collection.
|
/// An enum representing the type of view for a library or collection.
|
||||||
|
@ -6,33 +6,108 @@
|
||||||
public enum ViewType
|
public enum ViewType
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Shows banners.
|
/// Shows albums.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
Banner = 0,
|
Albums = 0,
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Shows a list of content.
|
/// Shows album artists.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
List = 1,
|
AlbumArtists = 1,
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Shows poster artwork.
|
/// Shows artists.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
Poster = 2,
|
Artists = 2,
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Shows poster artwork with a card containing the name and year.
|
/// Shows channels.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
PosterCard = 3,
|
Channels = 3,
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Shows a thumbnail.
|
/// Shows collections.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
Thumb = 4,
|
Collections = 4,
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Shows a thumbnail with a card containing the name and year.
|
/// Shows episodes.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
ThumbCard = 5
|
Episodes = 5,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Shows favorites.
|
||||||
|
/// </summary>
|
||||||
|
Favorites = 6,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Shows genres.
|
||||||
|
/// </summary>
|
||||||
|
Genres = 7,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Shows guide.
|
||||||
|
/// </summary>
|
||||||
|
Guide = 8,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Shows movies.
|
||||||
|
/// </summary>
|
||||||
|
Movies = 9,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Shows networks.
|
||||||
|
/// </summary>
|
||||||
|
Networks = 10,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Shows playlists.
|
||||||
|
/// </summary>
|
||||||
|
Playlists = 11,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Shows programs.
|
||||||
|
/// </summary>
|
||||||
|
Programs = 12,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Shows recordings.
|
||||||
|
/// </summary>
|
||||||
|
Recordings = 13,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Shows schedule.
|
||||||
|
/// </summary>
|
||||||
|
Schedule = 14,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Shows series.
|
||||||
|
/// </summary>
|
||||||
|
Series = 15,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Shows shows.
|
||||||
|
/// </summary>
|
||||||
|
Shows = 16,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Shows songs.
|
||||||
|
/// </summary>
|
||||||
|
Songs = 17,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Shows songs.
|
||||||
|
/// </summary>
|
||||||
|
Suggestions = 18,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Shows trailers.
|
||||||
|
/// </summary>
|
||||||
|
Trailers = 19,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Shows upcoming.
|
||||||
|
/// </summary>
|
||||||
|
Upcoming = 20
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user