display additional users in dashboard

This commit is contained in:
Luke Pulverenti 2014-01-03 21:59:20 -05:00
parent 135168b0e0
commit f93fb4650c
5 changed files with 18 additions and 12 deletions

View File

@ -239,7 +239,7 @@ namespace MediaBrowser.Api
if (!user.Configuration.EnableRemoteControlOfOtherUsers)
{
result = result.Where(i => !i.UserId.HasValue || i.UserId.Value == request.ControllableByUserId.Value);
result = result.Where(i => !i.UserId.HasValue || i.ContainsUser(request.ControllableByUserId.Value));
}
}

View File

@ -2,6 +2,7 @@
using MediaBrowser.Model.Session;
using System;
using System.Collections.Generic;
using System.Linq;
namespace MediaBrowser.Controller.Session
{
@ -14,10 +15,10 @@ namespace MediaBrowser.Controller.Session
{
QueueableMediaTypes = new List<string>();
AdditionalUsersPresent = new List<SessionUserInfo>();
AdditionalUsers = new List<SessionUserInfo>();
}
public List<SessionUserInfo> AdditionalUsersPresent { get; set; }
public List<SessionUserInfo> AdditionalUsers { get; set; }
/// <summary>
/// Gets or sets the remote end point.
@ -172,5 +173,10 @@ namespace MediaBrowser.Controller.Session
return false;
}
}
public bool ContainsUser(Guid userId)
{
return (UserId ?? Guid.Empty) == UserId || AdditionalUsers.Any(i => userId == new Guid(i.UserId));
}
}
}

View File

@ -47,7 +47,7 @@ namespace MediaBrowser.Model.Session
/// Gets or sets the additional users present.
/// </summary>
/// <value>The additional users present.</value>
public List<SessionUserInfo> AdditionalUsersPresent { get; set; }
public List<SessionUserInfo> AdditionalUsers { get; set; }
/// <summary>
/// Gets or sets the application version.
@ -137,7 +137,7 @@ namespace MediaBrowser.Model.Session
public SessionInfoDto()
{
AdditionalUsersPresent = new List<SessionUserInfo>();
AdditionalUsers = new List<SessionUserInfo>();
}
}

View File

@ -245,7 +245,7 @@ namespace MediaBrowser.Server.Implementations.Dto
CanSeek = session.CanSeek,
QueueableMediaTypes = session.QueueableMediaTypes,
RemoteEndPoint = session.RemoteEndPoint,
AdditionalUsersPresent = session.AdditionalUsersPresent
AdditionalUsers = session.AdditionalUsers
};
if (session.NowPlayingItem != null)

View File

@ -236,7 +236,7 @@ namespace MediaBrowser.Server.Implementations.Session
if (!userId.HasValue)
{
connection.AdditionalUsersPresent.Clear();
connection.AdditionalUsers.Clear();
}
if (connection.SessionController == null)
@ -264,7 +264,7 @@ namespace MediaBrowser.Server.Implementations.Session
users.Add(user);
var additionalUsers = session.AdditionalUsersPresent
var additionalUsers = session.AdditionalUsers
.Select(i => _userManager.GetUserById(new Guid(i.UserId)))
.Where(i => i != null);
@ -753,11 +753,11 @@ namespace MediaBrowser.Server.Implementations.Session
throw new ArgumentException("The requested user is already the primary user of the session.");
}
if (session.AdditionalUsersPresent.All(i => new Guid(i.UserId) != userId))
if (session.AdditionalUsers.All(i => new Guid(i.UserId) != userId))
{
var user = _userManager.GetUserById(userId);
session.AdditionalUsersPresent.Add(new SessionUserInfo
session.AdditionalUsers.Add(new SessionUserInfo
{
UserId = userId.ToString("N"),
UserName = user.Name
@ -786,11 +786,11 @@ namespace MediaBrowser.Server.Implementations.Session
throw new ArgumentException("The requested user is already the primary user of the session.");
}
var user = session.AdditionalUsersPresent.FirstOrDefault(i => new Guid(i.UserId) == userId);
var user = session.AdditionalUsers.FirstOrDefault(i => new Guid(i.UserId) == userId);
if (user != null)
{
session.AdditionalUsersPresent.Remove(user);
session.AdditionalUsers.Remove(user);
}
}
}