mirror of
https://github.com/lantean-code/qbtmud.git
synced 2025-10-22 20:42:24 +00:00
Fix issue wtih toolbar
This commit is contained in:
@@ -10,7 +10,8 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
<CascadingValue Value="Torrents">
|
<CascadingValue Value="Torrents">
|
||||||
<CascadingValue Value="MainData">
|
<CascadingValue Value="_torrentsVersion" Name="TorrentsVersion">
|
||||||
|
<CascadingValue Value="MainData">
|
||||||
<CascadingValue Value="Preferences">
|
<CascadingValue Value="Preferences">
|
||||||
<CascadingValue Value="SortColumnChanged" Name="SortColumnChanged">
|
<CascadingValue Value="SortColumnChanged" Name="SortColumnChanged">
|
||||||
<CascadingValue Value="SortColumn" Name="SortColumn">
|
<CascadingValue Value="SortColumn" Name="SortColumn">
|
||||||
@@ -65,5 +66,6 @@
|
|||||||
@DisplayHelpers.Size(MainData?.ServerState.UploadInfoData, "(", ")")
|
@DisplayHelpers.Size(MainData?.ServerState.UploadInfoData, "(", ")")
|
||||||
</MudText>
|
</MudText>
|
||||||
</MudAppBar>
|
</MudAppBar>
|
||||||
|
</CascadingValue>
|
||||||
</CascadingValue>
|
</CascadingValue>
|
||||||
</CascadingValue>
|
</CascadingValue>
|
||||||
|
@@ -63,6 +63,7 @@ namespace Lantean.QBTMud.Layout
|
|||||||
private IReadOnlyList<Torrent> _visibleTorrents = Array.Empty<Torrent>();
|
private IReadOnlyList<Torrent> _visibleTorrents = Array.Empty<Torrent>();
|
||||||
|
|
||||||
private bool _torrentsDirty = true;
|
private bool _torrentsDirty = true;
|
||||||
|
private int _torrentsVersion;
|
||||||
|
|
||||||
private IReadOnlyList<Torrent> GetTorrents()
|
private IReadOnlyList<Torrent> GetTorrents()
|
||||||
{
|
{
|
||||||
@@ -157,6 +158,10 @@ namespace Lantean.QBTMud.Layout
|
|||||||
{
|
{
|
||||||
MarkTorrentsDirty();
|
MarkTorrentsDirty();
|
||||||
}
|
}
|
||||||
|
else if (dataChanged)
|
||||||
|
{
|
||||||
|
IncrementTorrentsVersion();
|
||||||
|
}
|
||||||
shouldRender = dataChanged;
|
shouldRender = dataChanged;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -256,6 +261,15 @@ namespace Lantean.QBTMud.Layout
|
|||||||
private void MarkTorrentsDirty()
|
private void MarkTorrentsDirty()
|
||||||
{
|
{
|
||||||
_torrentsDirty = true;
|
_torrentsDirty = true;
|
||||||
|
IncrementTorrentsVersion();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void IncrementTorrentsVersion()
|
||||||
|
{
|
||||||
|
unchecked
|
||||||
|
{
|
||||||
|
_torrentsVersion++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
using Lantean.QBitTorrentClient;
|
using Lantean.QBitTorrentClient;
|
||||||
using Lantean.QBTMud.Components.UI;
|
using Lantean.QBTMud.Components.UI;
|
||||||
using Lantean.QBTMud.Helpers;
|
using Lantean.QBTMud.Helpers;
|
||||||
using Lantean.QBTMud.Models;
|
using Lantean.QBTMud.Models;
|
||||||
@@ -43,6 +43,9 @@ namespace Lantean.QBTMud.Pages
|
|||||||
[CascadingParameter(Name = "LostConnection")]
|
[CascadingParameter(Name = "LostConnection")]
|
||||||
public bool LostConnection { get; set; }
|
public bool LostConnection { get; set; }
|
||||||
|
|
||||||
|
[CascadingParameter(Name = "TorrentsVersion")]
|
||||||
|
public int TorrentsVersion { get; set; }
|
||||||
|
|
||||||
[CascadingParameter(Name = "SearchTermChanged")]
|
[CascadingParameter(Name = "SearchTermChanged")]
|
||||||
public EventCallback<string> SearchTermChanged { get; set; }
|
public EventCallback<string> SearchTermChanged { get; set; }
|
||||||
|
|
||||||
@@ -59,7 +62,7 @@ namespace Lantean.QBTMud.Pages
|
|||||||
|
|
||||||
protected HashSet<Torrent> SelectedItems { get; set; } = [];
|
protected HashSet<Torrent> SelectedItems { get; set; } = [];
|
||||||
|
|
||||||
protected bool ToolbarButtonsEnabled => SelectedItems.Count > 0;
|
protected bool ToolbarButtonsEnabled => _toolbarButtonsEnabled;
|
||||||
|
|
||||||
protected DynamicTable<Torrent>? Table { get; set; }
|
protected DynamicTable<Torrent>? Table { get; set; }
|
||||||
|
|
||||||
@@ -71,9 +74,11 @@ namespace Lantean.QBTMud.Pages
|
|||||||
private QBitTorrentClient.Models.Preferences? _lastPreferences;
|
private QBitTorrentClient.Models.Preferences? _lastPreferences;
|
||||||
private bool _lastLostConnection;
|
private bool _lastLostConnection;
|
||||||
private bool _hasRendered;
|
private bool _hasRendered;
|
||||||
private bool _pendingSelectionChange;
|
|
||||||
private int _lastSelectionCount;
|
private int _lastSelectionCount;
|
||||||
|
private int _lastTorrentsVersion = -1;
|
||||||
|
private bool _pendingSelectionChange;
|
||||||
|
|
||||||
|
private bool _toolbarButtonsEnabled;
|
||||||
protected override async Task OnAfterRenderAsync(bool firstRender)
|
protected override async Task OnAfterRenderAsync(bool firstRender)
|
||||||
{
|
{
|
||||||
if (firstRender)
|
if (firstRender)
|
||||||
@@ -91,8 +96,9 @@ namespace Lantean.QBTMud.Pages
|
|||||||
_lastRenderedTorrents = Torrents;
|
_lastRenderedTorrents = Torrents;
|
||||||
_lastPreferences = Preferences;
|
_lastPreferences = Preferences;
|
||||||
_lastLostConnection = LostConnection;
|
_lastLostConnection = LostConnection;
|
||||||
_pendingSelectionChange = false;
|
_lastTorrentsVersion = TorrentsVersion;
|
||||||
_lastSelectionCount = SelectedItems.Count;
|
_lastSelectionCount = SelectedItems.Count;
|
||||||
|
_toolbarButtonsEnabled = _lastSelectionCount > 0;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -100,6 +106,18 @@ namespace Lantean.QBTMud.Pages
|
|||||||
{
|
{
|
||||||
_pendingSelectionChange = false;
|
_pendingSelectionChange = false;
|
||||||
_lastSelectionCount = SelectedItems.Count;
|
_lastSelectionCount = SelectedItems.Count;
|
||||||
|
_toolbarButtonsEnabled = _lastSelectionCount > 0;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_lastTorrentsVersion != TorrentsVersion)
|
||||||
|
{
|
||||||
|
_lastTorrentsVersion = TorrentsVersion;
|
||||||
|
_lastRenderedTorrents = Torrents;
|
||||||
|
_lastPreferences = Preferences;
|
||||||
|
_lastLostConnection = LostConnection;
|
||||||
|
_lastSelectionCount = SelectedItems.Count;
|
||||||
|
_toolbarButtonsEnabled = _lastSelectionCount > 0;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -109,6 +127,7 @@ namespace Lantean.QBTMud.Pages
|
|||||||
_lastPreferences = Preferences;
|
_lastPreferences = Preferences;
|
||||||
_lastLostConnection = LostConnection;
|
_lastLostConnection = LostConnection;
|
||||||
_lastSelectionCount = SelectedItems.Count;
|
_lastSelectionCount = SelectedItems.Count;
|
||||||
|
_toolbarButtonsEnabled = _lastSelectionCount > 0;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -116,6 +135,7 @@ namespace Lantean.QBTMud.Pages
|
|||||||
{
|
{
|
||||||
_lastPreferences = Preferences;
|
_lastPreferences = Preferences;
|
||||||
_lastSelectionCount = SelectedItems.Count;
|
_lastSelectionCount = SelectedItems.Count;
|
||||||
|
_toolbarButtonsEnabled = _lastSelectionCount > 0;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -123,6 +143,14 @@ namespace Lantean.QBTMud.Pages
|
|||||||
{
|
{
|
||||||
_lastLostConnection = LostConnection;
|
_lastLostConnection = LostConnection;
|
||||||
_lastSelectionCount = SelectedItems.Count;
|
_lastSelectionCount = SelectedItems.Count;
|
||||||
|
_toolbarButtonsEnabled = _lastSelectionCount > 0;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_lastSelectionCount != SelectedItems.Count)
|
||||||
|
{
|
||||||
|
_lastSelectionCount = SelectedItems.Count;
|
||||||
|
_toolbarButtonsEnabled = _lastSelectionCount > 0;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -132,12 +160,9 @@ namespace Lantean.QBTMud.Pages
|
|||||||
protected void SelectedItemsChanged(HashSet<Torrent> selectedItems)
|
protected void SelectedItemsChanged(HashSet<Torrent> selectedItems)
|
||||||
{
|
{
|
||||||
SelectedItems = selectedItems;
|
SelectedItems = selectedItems;
|
||||||
if (_lastSelectionCount != SelectedItems.Count)
|
_toolbarButtonsEnabled = SelectedItems.Count > 0;
|
||||||
{
|
_pendingSelectionChange = true;
|
||||||
_pendingSelectionChange = true;
|
InvokeAsync(StateHasChanged);
|
||||||
_lastSelectionCount = SelectedItems.Count;
|
|
||||||
InvokeAsync(StateHasChanged);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected async Task SortDirectionChangedHandler(SortDirection sortDirection)
|
protected async Task SortDirectionChangedHandler(SortDirection sortDirection)
|
||||||
@@ -311,3 +336,4 @@ namespace Lantean.QBTMud.Pages
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
5
global.json
Normal file
5
global.json
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
{
|
||||||
|
"sdk": {
|
||||||
|
"version": "9.0.306"
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user