aboutsummaryrefslogtreecommitdiff
path: root/Jellyfin.Server.Implementations/Users/DisplayPreferencesManager.cs
diff options
context:
space:
mode:
authorcrobibero <cody@robibe.ro>2020-12-03 13:51:12 -0700
committercrobibero <cody@robibe.ro>2020-12-03 13:51:12 -0700
commitb0c79edd2c25f560208a40aedea05498d48ca80e (patch)
tree4052b66cf1234c7d71bc122a96f93382e2eee566 /Jellyfin.Server.Implementations/Users/DisplayPreferencesManager.cs
parent4a3411cad17c95f3afe0870a1ff3a9afc10286fa (diff)
Add support for custom item display preferences
Diffstat (limited to 'Jellyfin.Server.Implementations/Users/DisplayPreferencesManager.cs')
-rw-r--r--Jellyfin.Server.Implementations/Users/DisplayPreferencesManager.cs24
1 files changed, 24 insertions, 0 deletions
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
@@ -67,6 +67,30 @@ namespace Jellyfin.Server.Implementations.Users
}
/// <inheritdoc />
+ public IDictionary<string, string> 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);
+ }
+
+ /// <inheritdoc />
+ public void SetCustomItemDisplayPreferences(Guid userId, string client, Dictionary<string, string> 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));
+ }
+ }
+
+ /// <inheritdoc />
public void SaveChanges()
{
_dbContext.SaveChanges();