Scroll to new group node

This commit is contained in:
DHR60 2026-02-27 17:00:39 +08:00
parent 339919b080
commit 94f15b9150

View file

@ -8,6 +8,7 @@ public class ProfilesViewModel : MyReactiveObject
private string _serverFilter = string.Empty; private string _serverFilter = string.Empty;
private Dictionary<string, bool> _dicHeaderSort = new(); private Dictionary<string, bool> _dicHeaderSort = new();
private SpeedtestService? _speedtestService; private SpeedtestService? _speedtestService;
private string? _pendingSelectIndexId;
#endregion private prop #endregion private prop
@ -362,15 +363,14 @@ public class ProfilesViewModel : MyReactiveObject
ProfileItems.AddRange(lstModel); ProfileItems.AddRange(lstModel);
if (lstModel.Count > 0) if (lstModel.Count > 0)
{ {
var selected = lstModel.FirstOrDefault(t => t.IndexId == _config.IndexId); ProfileItemModel? selected = null;
if (selected != null) if (!_pendingSelectIndexId.IsNullOrEmpty())
{ {
SelectedProfile = selected; selected = lstModel.FirstOrDefault(t => t.IndexId == _pendingSelectIndexId);
} _pendingSelectIndexId = null;
else
{
SelectedProfile = lstModel.First();
} }
selected ??= lstModel.FirstOrDefault(t => t.IndexId == _config.IndexId);
SelectedProfile = selected ?? lstModel.First();
} }
await _updateView?.Invoke(EViewAction.DispatcherRefreshServersBiz, null); await _updateView?.Invoke(EViewAction.DispatcherRefreshServersBiz, null);
@ -619,6 +619,7 @@ public class ProfilesViewModel : MyReactiveObject
NoticeManager.Instance.Enqueue(ResUI.OperationFailed); NoticeManager.Instance.Enqueue(ResUI.OperationFailed);
return; return;
} }
_pendingSelectIndexId = ret.Data?.ToString();
await RefreshServers(); await RefreshServers();
} }