mirror of
https://github.com/jellyfin/jellyfin.git
synced 2025-07-09 03:04:24 -04:00
moved display preferences repo off of the kernel
This commit is contained in:
parent
31c2d98532
commit
23c8a91976
@ -88,12 +88,6 @@ namespace MediaBrowser.Controller
|
|||||||
/// <value>The user repository.</value>
|
/// <value>The user repository.</value>
|
||||||
public IUserRepository UserRepository { get; set; }
|
public IUserRepository UserRepository { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets the active user repository
|
|
||||||
/// </summary>
|
|
||||||
/// <value>The display preferences repository.</value>
|
|
||||||
public IDisplayPreferencesRepository DisplayPreferencesRepository { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the list of available item repositories
|
/// Gets the list of available item repositories
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -106,12 +100,6 @@ namespace MediaBrowser.Controller
|
|||||||
/// <value>The item repository.</value>
|
/// <value>The item repository.</value>
|
||||||
public IItemRepository ItemRepository { get; set; }
|
public IItemRepository ItemRepository { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets the list of available DisplayPreferencesRepositories
|
|
||||||
/// </summary>
|
|
||||||
/// <value>The display preferences repositories.</value>
|
|
||||||
public IEnumerable<IDisplayPreferencesRepository> DisplayPreferencesRepositories { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the list of available item repositories
|
/// Gets the list of available item repositories
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -155,11 +143,7 @@ namespace MediaBrowser.Controller
|
|||||||
UserDataRepository = GetRepository(UserDataRepositories, configurationManager.Configuration.UserDataRepository);
|
UserDataRepository = GetRepository(UserDataRepositories, configurationManager.Configuration.UserDataRepository);
|
||||||
var userDataRepoTask = UserDataRepository.Initialize();
|
var userDataRepoTask = UserDataRepository.Initialize();
|
||||||
|
|
||||||
// Get the current display preferences repository
|
return Task.WhenAll(itemRepoTask, userRepoTask, userDataRepoTask);
|
||||||
DisplayPreferencesRepository = GetRepository(DisplayPreferencesRepositories, configurationManager.Configuration.DisplayPreferencesRepository);
|
|
||||||
var displayPreferencesRepoTask = DisplayPreferencesRepository.Initialize();
|
|
||||||
|
|
||||||
return Task.WhenAll(itemRepoTask, userRepoTask, userDataRepoTask, displayPreferencesRepoTask);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
using MediaBrowser.Controller;
|
using MediaBrowser.Controller.Library;
|
||||||
using MediaBrowser.Controller.Library;
|
using MediaBrowser.Controller.Persistence;
|
||||||
using MediaBrowser.Model.Entities;
|
using MediaBrowser.Model.Entities;
|
||||||
using MediaBrowser.Model.Logging;
|
using MediaBrowser.Model.Logging;
|
||||||
using System;
|
using System;
|
||||||
@ -24,6 +24,12 @@ namespace MediaBrowser.Server.Implementations.Library
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
private readonly ConcurrentDictionary<Guid, Task<DisplayPreferences>> _displayPreferences = new ConcurrentDictionary<Guid, Task<DisplayPreferences>>();
|
private readonly ConcurrentDictionary<Guid, Task<DisplayPreferences>> _displayPreferences = new ConcurrentDictionary<Guid, Task<DisplayPreferences>>();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the active user repository
|
||||||
|
/// </summary>
|
||||||
|
/// <value>The display preferences repository.</value>
|
||||||
|
public IDisplayPreferencesRepository Repository { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes a new instance of the <see cref="DisplayPreferencesManager"/> class.
|
/// Initializes a new instance of the <see cref="DisplayPreferencesManager"/> class.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -50,7 +56,7 @@ namespace MediaBrowser.Server.Implementations.Library
|
|||||||
/// <returns>DisplayPreferences.</returns>
|
/// <returns>DisplayPreferences.</returns>
|
||||||
private async Task<DisplayPreferences> RetrieveDisplayPreferences(Guid displayPreferencesId)
|
private async Task<DisplayPreferences> RetrieveDisplayPreferences(Guid displayPreferencesId)
|
||||||
{
|
{
|
||||||
var displayPreferences = await Kernel.Instance.DisplayPreferencesRepository.GetDisplayPreferences(displayPreferencesId).ConfigureAwait(false);
|
var displayPreferences = await Repository.GetDisplayPreferences(displayPreferencesId).ConfigureAwait(false);
|
||||||
|
|
||||||
return displayPreferences ?? new DisplayPreferences { Id = displayPreferencesId };
|
return displayPreferences ?? new DisplayPreferences { Id = displayPreferencesId };
|
||||||
}
|
}
|
||||||
@ -74,7 +80,7 @@ namespace MediaBrowser.Server.Implementations.Library
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
await Kernel.Instance.DisplayPreferencesRepository.SaveDisplayPreferences(displayPreferences,
|
await Repository.SaveDisplayPreferences(displayPreferences,
|
||||||
cancellationToken).ConfigureAwait(false);
|
cancellationToken).ConfigureAwait(false);
|
||||||
|
|
||||||
var newValue = Task.FromResult(displayPreferences);
|
var newValue = Task.FromResult(displayPreferences);
|
||||||
|
@ -220,6 +220,7 @@ namespace MediaBrowser.ServerApplication
|
|||||||
|
|
||||||
RegisterSingleInstance<ILibrarySearchEngine>(() => new LuceneSearchEngine());
|
RegisterSingleInstance<ILibrarySearchEngine>(() => new LuceneSearchEngine());
|
||||||
|
|
||||||
|
await ConfigureRepositories().ConfigureAwait(false);
|
||||||
SetKernelProperties();
|
SetKernelProperties();
|
||||||
SetStaticProperties();
|
SetStaticProperties();
|
||||||
}
|
}
|
||||||
@ -235,7 +236,6 @@ namespace MediaBrowser.ServerApplication
|
|||||||
Parallel.Invoke(
|
Parallel.Invoke(
|
||||||
() => ServerKernel.UserDataRepositories = GetExports<IUserDataRepository>(),
|
() => ServerKernel.UserDataRepositories = GetExports<IUserDataRepository>(),
|
||||||
() => ServerKernel.UserRepositories = GetExports<IUserRepository>(),
|
() => ServerKernel.UserRepositories = GetExports<IUserRepository>(),
|
||||||
() => ServerKernel.DisplayPreferencesRepositories = GetExports<IDisplayPreferencesRepository>(),
|
|
||||||
() => ServerKernel.ItemRepositories = GetExports<IItemRepository>(),
|
() => ServerKernel.ItemRepositories = GetExports<IItemRepository>(),
|
||||||
() => ServerKernel.WeatherProviders = GetExports<IWeatherProvider>(),
|
() => ServerKernel.WeatherProviders = GetExports<IWeatherProvider>(),
|
||||||
() => ServerKernel.ImageEnhancers = GetExports<IImageEnhancer>().OrderBy(e => e.Priority).ToArray(),
|
() => ServerKernel.ImageEnhancers = GetExports<IImageEnhancer>().OrderBy(e => e.Priority).ToArray(),
|
||||||
@ -243,6 +243,21 @@ namespace MediaBrowser.ServerApplication
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Configures the repositories.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>Task.</returns>
|
||||||
|
private async Task ConfigureRepositories()
|
||||||
|
{
|
||||||
|
var displayPreferencesRepositories = GetExports<IDisplayPreferencesRepository>();
|
||||||
|
|
||||||
|
var repo = GetRepository(displayPreferencesRepositories, ServerConfigurationManager.Configuration.DisplayPreferencesRepository);
|
||||||
|
|
||||||
|
await repo.Initialize().ConfigureAwait(false);
|
||||||
|
|
||||||
|
((DisplayPreferencesManager)DisplayPreferencesManager).Repository = repo;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Dirty hacks
|
/// Dirty hacks
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -456,5 +471,21 @@ namespace MediaBrowser.ServerApplication
|
|||||||
process.WaitForExit();
|
process.WaitForExit();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the repository.
|
||||||
|
/// </summary>
|
||||||
|
/// <typeparam name="T"></typeparam>
|
||||||
|
/// <param name="repositories">The repositories.</param>
|
||||||
|
/// <param name="name">The name.</param>
|
||||||
|
/// <returns>``0.</returns>
|
||||||
|
private T GetRepository<T>(IEnumerable<T> repositories, string name)
|
||||||
|
where T : class, IRepository
|
||||||
|
{
|
||||||
|
var enumerable = repositories as T[] ?? repositories.ToArray();
|
||||||
|
|
||||||
|
return enumerable.FirstOrDefault(r => string.Equals(r.Name, name, StringComparison.OrdinalIgnoreCase)) ??
|
||||||
|
enumerable.FirstOrDefault();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user