mirror of
https://github.com/jellyfin/jellyfin.git
synced 2025-07-09 03:04:24 -04:00
Fix UpdateDeviceOptions
This commit is contained in:
parent
3123ea2a94
commit
6b24cc6d1f
@ -49,9 +49,15 @@ namespace Jellyfin.Server.Implementations.Devices
|
|||||||
public async Task UpdateDeviceOptions(string deviceId, DeviceOptions options)
|
public async Task UpdateDeviceOptions(string deviceId, DeviceOptions options)
|
||||||
{
|
{
|
||||||
await using var dbContext = _dbProvider.CreateContext();
|
await using var dbContext = _dbProvider.CreateContext();
|
||||||
await dbContext.Database
|
var deviceOptions = await dbContext.DeviceOptions.AsQueryable().FirstOrDefaultAsync(dev => dev.DeviceId == deviceId).ConfigureAwait(false);
|
||||||
.ExecuteSqlInterpolatedAsync($"UPDATE [DeviceOptions] SET [CustomName] = {options.CustomName}")
|
if (deviceOptions == null)
|
||||||
.ConfigureAwait(false);
|
{
|
||||||
|
deviceOptions = new DeviceOptions(deviceId);
|
||||||
|
dbContext.DeviceOptions.Add(deviceOptions);
|
||||||
|
}
|
||||||
|
|
||||||
|
deviceOptions.CustomName = options.CustomName;
|
||||||
|
await dbContext.SaveChangesAsync().ConfigureAwait(false);
|
||||||
|
|
||||||
DeviceOptionsUpdated?.Invoke(this, new GenericEventArgs<Tuple<string, DeviceOptions>>(new Tuple<string, DeviceOptions>(deviceId, options)));
|
DeviceOptionsUpdated?.Invoke(this, new GenericEventArgs<Tuple<string, DeviceOptions>>(new Tuple<string, DeviceOptions>(deviceId, options)));
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user