Fix nullability on DisplayPreferencesDto

Remove duplicate, fix namespace
This commit is contained in:
Cody Robibero 2021-11-11 07:16:57 -07:00
parent 4c88bf3fe3
commit 3de86ffdb4
4 changed files with 14 additions and 117 deletions

View File

@ -8,7 +8,7 @@ using Jellyfin.Data.Entities;
using Jellyfin.Data.Enums; using Jellyfin.Data.Enums;
using MediaBrowser.Common.Extensions; using MediaBrowser.Common.Extensions;
using MediaBrowser.Controller; using MediaBrowser.Controller;
using MediaBrowser.Model.Entities; using MediaBrowser.Model.Dto;
using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
@ -143,21 +143,24 @@ namespace Jellyfin.Api.Controllers
existingDisplayPreferences.ScrollDirection = displayPreferences.ScrollDirection; existingDisplayPreferences.ScrollDirection = displayPreferences.ScrollDirection;
existingDisplayPreferences.ChromecastVersion = displayPreferences.CustomPrefs.TryGetValue("chromecastVersion", out var chromecastVersion) existingDisplayPreferences.ChromecastVersion = displayPreferences.CustomPrefs.TryGetValue("chromecastVersion", out var chromecastVersion)
&& !string.IsNullOrEmpty(chromecastVersion)
? Enum.Parse<ChromecastVersion>(chromecastVersion, true) ? Enum.Parse<ChromecastVersion>(chromecastVersion, true)
: ChromecastVersion.Stable; : ChromecastVersion.Stable;
displayPreferences.CustomPrefs.Remove("chromecastVersion"); displayPreferences.CustomPrefs.Remove("chromecastVersion");
existingDisplayPreferences.EnableNextVideoInfoOverlay = displayPreferences.CustomPrefs.TryGetValue("enableNextVideoInfoOverlay", out var enableNextVideoInfoOverlay) existingDisplayPreferences.EnableNextVideoInfoOverlay = !displayPreferences.CustomPrefs.TryGetValue("enableNextVideoInfoOverlay", out var enableNextVideoInfoOverlay)
? bool.Parse(enableNextVideoInfoOverlay) || string.IsNullOrEmpty(enableNextVideoInfoOverlay)
: true; || bool.Parse(enableNextVideoInfoOverlay);
displayPreferences.CustomPrefs.Remove("enableNextVideoInfoOverlay"); displayPreferences.CustomPrefs.Remove("enableNextVideoInfoOverlay");
existingDisplayPreferences.SkipBackwardLength = displayPreferences.CustomPrefs.TryGetValue("skipBackLength", out var skipBackLength) existingDisplayPreferences.SkipBackwardLength = displayPreferences.CustomPrefs.TryGetValue("skipBackLength", out var skipBackLength)
&& !string.IsNullOrEmpty(skipBackLength)
? int.Parse(skipBackLength, CultureInfo.InvariantCulture) ? int.Parse(skipBackLength, CultureInfo.InvariantCulture)
: 10000; : 10000;
displayPreferences.CustomPrefs.Remove("skipBackLength"); displayPreferences.CustomPrefs.Remove("skipBackLength");
existingDisplayPreferences.SkipForwardLength = displayPreferences.CustomPrefs.TryGetValue("skipForwardLength", out var skipForwardLength) existingDisplayPreferences.SkipForwardLength = displayPreferences.CustomPrefs.TryGetValue("skipForwardLength", out var skipForwardLength)
&& !string.IsNullOrEmpty(skipForwardLength)
? int.Parse(skipForwardLength, CultureInfo.InvariantCulture) ? int.Parse(skipForwardLength, CultureInfo.InvariantCulture)
: 30000; : 30000;
displayPreferences.CustomPrefs.Remove("skipForwardLength"); displayPreferences.CustomPrefs.Remove("skipForwardLength");
@ -196,7 +199,7 @@ namespace Jellyfin.Api.Controllers
} }
var itemPrefs = _displayPreferencesManager.GetItemDisplayPreferences(existingDisplayPreferences.UserId, itemId, existingDisplayPreferences.Client); var itemPrefs = _displayPreferencesManager.GetItemDisplayPreferences(existingDisplayPreferences.UserId, itemId, existingDisplayPreferences.Client);
itemPrefs.SortBy = displayPreferences.SortBy; itemPrefs.SortBy = displayPreferences.SortBy ?? "SortName";
itemPrefs.SortOrder = displayPreferences.SortOrder; itemPrefs.SortOrder = displayPreferences.SortOrder;
itemPrefs.RememberIndexing = displayPreferences.RememberIndexing; itemPrefs.RememberIndexing = displayPreferences.RememberIndexing;
itemPrefs.RememberSorting = displayPreferences.RememberSorting; itemPrefs.RememberSorting = displayPreferences.RememberSorting;

View File

@ -9,7 +9,7 @@ using Jellyfin.Data.Enums;
using Jellyfin.Server.Implementations; using Jellyfin.Server.Implementations;
using MediaBrowser.Controller; using MediaBrowser.Controller;
using MediaBrowser.Controller.Library; using MediaBrowser.Controller.Library;
using MediaBrowser.Model.Entities; using MediaBrowser.Model.Dto;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using SQLitePCL.pretty; using SQLitePCL.pretty;
@ -114,6 +114,7 @@ namespace Jellyfin.Server.Migrations.Routines
} }
var chromecastVersion = dto.CustomPrefs.TryGetValue("chromecastVersion", out var version) var chromecastVersion = dto.CustomPrefs.TryGetValue("chromecastVersion", out var version)
&& !string.IsNullOrEmpty(version)
? chromecastDict[version] ? chromecastDict[version]
: ChromecastVersion.Stable; : ChromecastVersion.Stable;
dto.CustomPrefs.Remove("chromecastVersion"); dto.CustomPrefs.Remove("chromecastVersion");

View File

@ -1,7 +1,7 @@
using System.Collections.Generic; using System.Collections.Generic;
using Jellyfin.Data.Enums; using Jellyfin.Data.Enums;
namespace Jellyfin.Api.Models.DisplayPreferencesDtos namespace MediaBrowser.Model.Dto
{ {
/// <summary> /// <summary>
/// Defines the display preferences for any item that supports them (usually Folders). /// Defines the display preferences for any item that supports them (usually Folders).
@ -17,7 +17,7 @@ namespace Jellyfin.Api.Models.DisplayPreferencesDtos
PrimaryImageHeight = 250; PrimaryImageHeight = 250;
PrimaryImageWidth = 250; PrimaryImageWidth = 250;
ShowBackdrop = true; ShowBackdrop = true;
CustomPrefs = new Dictionary<string, string>(); CustomPrefs = new Dictionary<string, string?>();
} }
/// <summary> /// <summary>
@ -66,7 +66,7 @@ namespace Jellyfin.Api.Models.DisplayPreferencesDtos
/// Gets the custom prefs. /// Gets the custom prefs.
/// </summary> /// </summary>
/// <value>The custom prefs.</value> /// <value>The custom prefs.</value>
public Dictionary<string, string> CustomPrefs { get; } public Dictionary<string, string?> CustomPrefs { get; }
/// <summary> /// <summary>
/// Gets or sets the scroll direction. /// Gets or sets the scroll direction.

View File

@ -1,107 +0,0 @@
#nullable disable
using System.Collections.Generic;
using Jellyfin.Data.Enums;
namespace MediaBrowser.Model.Entities
{
/// <summary>
/// Defines the display preferences for any item that supports them (usually Folders).
/// </summary>
public class DisplayPreferencesDto
{
/// <summary>
/// Initializes a new instance of the <see cref="DisplayPreferencesDto" /> class.
/// </summary>
public DisplayPreferencesDto()
{
RememberIndexing = false;
PrimaryImageHeight = 250;
PrimaryImageWidth = 250;
ShowBackdrop = true;
CustomPrefs = new Dictionary<string, string>();
}
/// <summary>
/// Gets or sets the user id.
/// </summary>
/// <value>The user id.</value>
public string Id { get; set; }
/// <summary>
/// Gets or sets the type of the view.
/// </summary>
/// <value>The type of the view.</value>
public string ViewType { get; set; }
/// <summary>
/// Gets or sets the sort by.
/// </summary>
/// <value>The sort by.</value>
public string SortBy { get; set; }
/// <summary>
/// Gets or sets the index by.
/// </summary>
/// <value>The index by.</value>
public string IndexBy { get; set; }
/// <summary>
/// Gets or sets a value indicating whether [remember indexing].
/// </summary>
/// <value><c>true</c> if [remember indexing]; otherwise, <c>false</c>.</value>
public bool RememberIndexing { get; set; }
/// <summary>
/// Gets or sets the height of the primary image.
/// </summary>
/// <value>The height of the primary image.</value>
public int PrimaryImageHeight { get; set; }
/// <summary>
/// Gets or sets the width of the primary image.
/// </summary>
/// <value>The width of the primary image.</value>
public int PrimaryImageWidth { get; set; }
/// <summary>
/// Gets or sets the custom prefs.
/// </summary>
/// <value>The custom prefs.</value>
public Dictionary<string, string> CustomPrefs { get; set; }
/// <summary>
/// Gets or sets the scroll direction.
/// </summary>
/// <value>The scroll direction.</value>
public ScrollDirection ScrollDirection { get; set; }
/// <summary>
/// Gets or sets a value indicating whether to show backdrops on this item.
/// </summary>
/// <value><c>true</c> if showing backdrops; otherwise, <c>false</c>.</value>
public bool ShowBackdrop { get; set; }
/// <summary>
/// Gets or sets a value indicating whether [remember sorting].
/// </summary>
/// <value><c>true</c> if [remember sorting]; otherwise, <c>false</c>.</value>
public bool RememberSorting { get; set; }
/// <summary>
/// Gets or sets the sort order.
/// </summary>
/// <value>The sort order.</value>
public SortOrder SortOrder { get; set; }
/// <summary>
/// Gets or sets a value indicating whether [show sidebar].
/// </summary>
/// <value><c>true</c> if [show sidebar]; otherwise, <c>false</c>.</value>
public bool ShowSidebar { get; set; }
/// <summary>
/// Gets or sets the client.
/// </summary>
public string Client { get; set; }
}
}