Add support for custom item display preferences

This commit is contained in:
crobibero
2020-12-03 13:51:12 -07:00
parent 4a3411cad1
commit b0c79edd2c
8 changed files with 842 additions and 41 deletions

View File

@@ -66,6 +66,30 @@ namespace Jellyfin.Server.Implementations.Users
.ToList();
}
/// <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()
{