diff --git a/Server/Components/Devices/DevicesFrame.razor b/Server/Components/Devices/DevicesFrame.razor index f80681cb7..061eb1971 100644 --- a/Server/Components/Devices/DevicesFrame.razor +++ b/Server/Components/Devices/DevicesFrame.razor @@ -69,7 +69,6 @@ - per page @@ -79,7 +78,7 @@
- @foreach (var device in DevicesForPage) + @foreach (var device in _devicesForPage) { diff --git a/Server/Components/Devices/DevicesFrame.razor.cs b/Server/Components/Devices/DevicesFrame.razor.cs index eb70220c6..1ff8736c6 100644 --- a/Server/Components/Devices/DevicesFrame.razor.cs +++ b/Server/Components/Devices/DevicesFrame.razor.cs @@ -31,6 +31,7 @@ public partial class DevicesFrame : AuthComponentBase, IDisposable private readonly List _allDevices = new(); private readonly string _deviceGroupAll = Guid.NewGuid().ToString(); private readonly string _deviceGroupNone = Guid.NewGuid().ToString(); + private readonly List _devicesForPage = new(); private readonly List _deviceGroups = new(); private readonly List _filteredDevices = new(); private readonly ConcurrentDictionary _remoteControlTargetLookup = new(); @@ -54,22 +55,6 @@ public partial class DevicesFrame : AuthComponentBase, IDisposable [Inject] private IDataService DataService { get; set; } - private IEnumerable 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 @@ private void FilterDevices() 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()