Change DevicesForPage to field.

This commit is contained in:
Jared Goodwin 2021-05-15 10:27:32 -07:00
parent c2b07180eb
commit 166b72ffa6
2 changed files with 13 additions and 18 deletions

View File

@ -69,7 +69,6 @@
<option value="50">50</option>
<option value="100">100</option>
<option value="200">200</option>
<option value="500">500</option>
</select>
<span class="ml-1 small">per page</span>
</div>
@ -79,7 +78,7 @@
</div>
</div>
<div id="deviceListDiv" class="p-2 mb-5">
@foreach (var device in DevicesForPage)
@foreach (var device in _devicesForPage)
{
<CascadingValue Value="this">
<DeviceCard @key="device.ID" Device="device" RemoteControlTargetLookup="_remoteControlTargetLookup" />

View File

@ -31,6 +31,7 @@ namespace Remotely.Server.Components.Devices
private readonly List<Device> _allDevices = new();
private readonly string _deviceGroupAll = Guid.NewGuid().ToString();
private readonly string _deviceGroupNone = Guid.NewGuid().ToString();
private readonly List<Device> _devicesForPage = new();
private readonly List<DeviceGroup> _deviceGroups = new();
private readonly List<Device> _filteredDevices = new();
private readonly ConcurrentDictionary<string, RemoteControlTarget> _remoteControlTargetLookup = new();
@ -54,22 +55,6 @@ namespace Remotely.Server.Components.Devices
[Inject]
private IDataService DataService { get; set; }
private IEnumerable<Device> DevicesForPage
{
get
{
var appendDevices = _filteredDevices.Where(x => AppState.DevicesFrameSelectedDevices.Contains(x.ID));
var skipCount = (_currentPage - 1) * _devicesPerPage;
var devicesForPage = _filteredDevices
.Except(appendDevices)
.Skip(skipCount)
.Take(_devicesPerPage);
return appendDevices.Concat(devicesForPage);
}
}
[Inject]
private IJsInterop JsInterop { get; set; }
@ -284,7 +269,18 @@ namespace Remotely.Server.Components.Devices
x.Platform?.Contains(_filter, StringComparison.OrdinalIgnoreCase) != true &&
x.Tags?.Contains(_filter, StringComparison.OrdinalIgnoreCase) != true);
}
var appendDevices = _filteredDevices.Where(x => AppState.DevicesFrameSelectedDevices.Contains(x.ID));
var skipCount = (_currentPage - 1) * _devicesPerPage;
var devicesForPage = _filteredDevices
.Except(appendDevices)
.Skip(skipCount)
.Take(_devicesPerPage);
_devicesForPage.Clear();
_devicesForPage.AddRange(devicesForPage);
}
}
private void PageDown()