diff options
| author | Luke <luke.pulverenti@gmail.com> | 2017-10-24 01:20:09 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2017-10-24 01:20:09 -0400 |
| commit | 0aac8045fb69ad1024859812a09e68070ea698f6 (patch) | |
| tree | 6e8b55133b0eeee606df5049497b80a612843733 /Emby.Server.Implementations/Devices/DeviceManager.cs | |
| parent | 7924bb7c9add449f61d8695add6f2f3fcbc18a0a (diff) | |
| parent | 6c5f3ce07e8b36299a4143dc609999d880e7bdfd (diff) | |
Merge pull request #2974 from MediaBrowser/beta
Beta
Diffstat (limited to 'Emby.Server.Implementations/Devices/DeviceManager.cs')
| -rw-r--r-- | Emby.Server.Implementations/Devices/DeviceManager.cs | 27 |
1 files changed, 15 insertions, 12 deletions
diff --git a/Emby.Server.Implementations/Devices/DeviceManager.cs b/Emby.Server.Implementations/Devices/DeviceManager.cs index 027a55516..ee4c4bb26 100644 --- a/Emby.Server.Implementations/Devices/DeviceManager.cs +++ b/Emby.Server.Implementations/Devices/DeviceManager.cs @@ -50,7 +50,7 @@ namespace Emby.Server.Implementations.Devices _network = network; } - public async Task<DeviceInfo> RegisterDevice(string reportedId, string name, string appName, string appVersion, string usedByUserId) + public DeviceInfo RegisterDevice(string reportedId, string name, string appName, string appVersion, string usedByUserId) { if (string.IsNullOrWhiteSpace(reportedId)) { @@ -76,14 +76,16 @@ namespace Emby.Server.Implementations.Devices device.DateLastModified = DateTime.UtcNow; - await _repo.SaveDevice(device).ConfigureAwait(false); + device.Name = string.IsNullOrWhiteSpace(device.CustomName) ? device.ReportedName : device.CustomName; + + _repo.SaveDevice(device); return device; } - public Task SaveCapabilities(string reportedId, ClientCapabilities capabilities) + public void SaveCapabilities(string reportedId, ClientCapabilities capabilities) { - return _repo.SaveCapabilities(reportedId, capabilities); + _repo.SaveCapabilities(reportedId, capabilities); } public ClientCapabilities GetCapabilities(string reportedId) @@ -98,13 +100,13 @@ namespace Emby.Server.Implementations.Devices public QueryResult<DeviceInfo> GetDevices(DeviceQuery query) { - IEnumerable<DeviceInfo> devices = _repo.GetDevices().OrderByDescending(i => i.DateLastModified); + IEnumerable<DeviceInfo> devices = _repo.GetDevices(); if (query.SupportsSync.HasValue) { var val = query.SupportsSync.Value; - devices = devices.Where(i => GetCapabilities(i.Id).SupportsSync == val); + devices = devices.Where(i => i.Capabilities.SupportsSync == val); } if (query.SupportsPersistentIdentifier.HasValue) @@ -113,8 +115,7 @@ namespace Emby.Server.Implementations.Devices devices = devices.Where(i => { - var caps = GetCapabilities(i.Id); - var deviceVal = caps.SupportsPersistentIdentifier; + var deviceVal = i.Capabilities.SupportsPersistentIdentifier; return deviceVal == val; }); } @@ -132,9 +133,9 @@ namespace Emby.Server.Implementations.Devices }; } - public Task DeleteDevice(string id) + public void DeleteDevice(string id) { - return _repo.DeleteDevice(id); + _repo.DeleteDevice(id); } public ContentUploadHistory GetCameraUploadHistory(string deviceId) @@ -213,14 +214,16 @@ namespace Emby.Server.Implementations.Devices get { return Path.Combine(_config.CommonApplicationPaths.DataPath, "camerauploads"); } } - public async Task UpdateDeviceInfo(string id, DeviceOptions options) + public void UpdateDeviceInfo(string id, DeviceOptions options) { var device = GetDevice(id); device.CustomName = options.CustomName; device.CameraUploadPath = options.CameraUploadPath; - await _repo.SaveDevice(device).ConfigureAwait(false); + device.Name = string.IsNullOrWhiteSpace(device.CustomName) ? device.ReportedName : device.CustomName; + + _repo.SaveDevice(device); EventHelper.FireEventIfNotNull(DeviceOptionsUpdated, this, new GenericEventArgs<DeviceInfo>(device), _logger); } |
