Session manager works with the userdata manager not the repository
This commit is contained in:
parent
08fb2707be
commit
038cfabca5
|
@ -41,7 +41,7 @@ namespace MediaBrowser.Server.Implementations.Session
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The _user data repository
|
/// The _user data repository
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private readonly IUserDataManager _userDataRepository;
|
private readonly IUserDataManager _userDataManager;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The _logger
|
/// The _logger
|
||||||
|
@ -94,9 +94,9 @@ namespace MediaBrowser.Server.Implementations.Session
|
||||||
|
|
||||||
private readonly SemaphoreSlim _sessionLock = new SemaphoreSlim(1, 1);
|
private readonly SemaphoreSlim _sessionLock = new SemaphoreSlim(1, 1);
|
||||||
|
|
||||||
public SessionManager(IUserDataManager userDataRepository, ILogger logger, ILibraryManager libraryManager, IUserManager userManager, IMusicManager musicManager, IDtoService dtoService, IImageProcessor imageProcessor, IJsonSerializer jsonSerializer, IServerApplicationHost appHost, IHttpClient httpClient, IAuthenticationRepository authRepo, IDeviceManager deviceManager, IMediaSourceManager mediaSourceManager)
|
public SessionManager(IUserDataManager userDataManager, ILogger logger, ILibraryManager libraryManager, IUserManager userManager, IMusicManager musicManager, IDtoService dtoService, IImageProcessor imageProcessor, IJsonSerializer jsonSerializer, IServerApplicationHost appHost, IHttpClient httpClient, IAuthenticationRepository authRepo, IDeviceManager deviceManager, IMediaSourceManager mediaSourceManager)
|
||||||
{
|
{
|
||||||
_userDataRepository = userDataRepository;
|
_userDataManager = userDataManager;
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
_libraryManager = libraryManager;
|
_libraryManager = libraryManager;
|
||||||
_userManager = userManager;
|
_userManager = userManager;
|
||||||
|
@ -631,7 +631,7 @@ namespace MediaBrowser.Server.Implementations.Session
|
||||||
/// <returns>Task.</returns>
|
/// <returns>Task.</returns>
|
||||||
private async Task OnPlaybackStart(Guid userId, IHasUserData item)
|
private async Task OnPlaybackStart(Guid userId, IHasUserData item)
|
||||||
{
|
{
|
||||||
var data = _userDataRepository.GetUserData(userId, item);
|
var data = _userDataManager.GetUserData(userId, item);
|
||||||
|
|
||||||
data.PlayCount++;
|
data.PlayCount++;
|
||||||
data.LastPlayedDate = DateTime.UtcNow;
|
data.LastPlayedDate = DateTime.UtcNow;
|
||||||
|
@ -641,7 +641,7 @@ namespace MediaBrowser.Server.Implementations.Session
|
||||||
data.Played = true;
|
data.Played = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
await _userDataRepository.SaveUserData(userId, item, data, UserDataSaveReason.PlaybackStart, CancellationToken.None).ConfigureAwait(false);
|
await _userDataManager.SaveUserData(userId, item, data, UserDataSaveReason.PlaybackStart, CancellationToken.None).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -708,17 +708,17 @@ namespace MediaBrowser.Server.Implementations.Session
|
||||||
|
|
||||||
private async Task OnPlaybackProgress(User user, BaseItem item, PlaybackProgressInfo info)
|
private async Task OnPlaybackProgress(User user, BaseItem item, PlaybackProgressInfo info)
|
||||||
{
|
{
|
||||||
var data = _userDataRepository.GetUserData(user.Id, item);
|
var data = _userDataManager.GetUserData(user.Id, item);
|
||||||
|
|
||||||
var positionTicks = info.PositionTicks;
|
var positionTicks = info.PositionTicks;
|
||||||
|
|
||||||
if (positionTicks.HasValue)
|
if (positionTicks.HasValue)
|
||||||
{
|
{
|
||||||
_userDataRepository.UpdatePlayState(item, data, positionTicks.Value);
|
_userDataManager.UpdatePlayState(item, data, positionTicks.Value);
|
||||||
|
|
||||||
UpdatePlaybackSettings(user, info, data);
|
UpdatePlaybackSettings(user, info, data);
|
||||||
|
|
||||||
await _userDataRepository.SaveUserData(user.Id, item, data, UserDataSaveReason.PlaybackProgress, CancellationToken.None).ConfigureAwait(false);
|
await _userDataManager.SaveUserData(user.Id, item, data, UserDataSaveReason.PlaybackProgress, CancellationToken.None).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -844,11 +844,11 @@ namespace MediaBrowser.Server.Implementations.Session
|
||||||
|
|
||||||
if (!playbackFailed)
|
if (!playbackFailed)
|
||||||
{
|
{
|
||||||
var data = _userDataRepository.GetUserData(userId, item);
|
var data = _userDataManager.GetUserData(userId, item);
|
||||||
|
|
||||||
if (positionTicks.HasValue)
|
if (positionTicks.HasValue)
|
||||||
{
|
{
|
||||||
playedToCompletion = _userDataRepository.UpdatePlayState(item, data, positionTicks.Value);
|
playedToCompletion = _userDataManager.UpdatePlayState(item, data, positionTicks.Value);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -859,7 +859,7 @@ namespace MediaBrowser.Server.Implementations.Session
|
||||||
playedToCompletion = true;
|
playedToCompletion = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
await _userDataRepository.SaveUserData(userId, item, data, UserDataSaveReason.PlaybackFinished, CancellationToken.None).ConfigureAwait(false);
|
await _userDataManager.SaveUserData(userId, item, data, UserDataSaveReason.PlaybackFinished, CancellationToken.None).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
return playedToCompletion;
|
return playedToCompletion;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user