From b0c79edd2c25f560208a40aedea05498d48ca80e Mon Sep 17 00:00:00 2001 From: crobibero Date: Thu, 3 Dec 2020 13:51:12 -0700 Subject: Add support for custom item display preferences --- .../Users/DisplayPreferencesManager.cs | 24 ++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'Jellyfin.Server.Implementations/Users') diff --git a/Jellyfin.Server.Implementations/Users/DisplayPreferencesManager.cs b/Jellyfin.Server.Implementations/Users/DisplayPreferencesManager.cs index 76f943385..1f3b4ff17 100644 --- a/Jellyfin.Server.Implementations/Users/DisplayPreferencesManager.cs +++ b/Jellyfin.Server.Implementations/Users/DisplayPreferencesManager.cs @@ -66,6 +66,30 @@ namespace Jellyfin.Server.Implementations.Users .ToList(); } + /// + public IDictionary ListCustomItemDisplayPreferences(Guid userId, string client) + { + return _dbContext.CustomItemDisplayPreferences + .AsQueryable() + .Where(prefs => prefs.UserId == userId && string.Equals(prefs.Client, client)) + .ToDictionary(prefs => prefs.Key, prefs => prefs.Value); + } + + /// + public void SetCustomItemDisplayPreferences(Guid userId, string client, Dictionary customPreferences) + { + var existingPrefs = _dbContext.CustomItemDisplayPreferences + .AsQueryable() + .Where(prefs => prefs.UserId == userId && string.Equals(prefs.Client, client)); + _dbContext.CustomItemDisplayPreferences.RemoveRange(existingPrefs); + + foreach (var (key, value) in customPreferences) + { + _dbContext.CustomItemDisplayPreferences + .Add(new CustomItemDisplayPreferences(userId, client, key, value)); + } + } + /// public void SaveChanges() { -- cgit v1.2.3