Fix tray server selection being cleared after refresh (#9927) (#9928)

* Fix tray server selection after refresh (#9927)

* Update StatusBarViewModel.cs

---------

Co-authored-by: 2dust <31833384+2dust@users.noreply.github.com>
This commit is contained in:
白龙
2026-08-14 10:38:27 +08:00
committed by GitHub
parent fb7033aab5
commit e7cc4c832e

View File

@@ -297,21 +297,14 @@ public partial class StatusBarViewModel : MyReactiveObject
return;
}
var models = new List<ComboItem>();
BlServers = true;
foreach (var it in lstModel)
{
var name = it.GetSummary();
var models = lstModel.Select(it => new ComboItem { ID = it.IndexId, Text = it.GetSummary() }).ToList();
var item = new ComboItem() { ID = it.IndexId, Text = name };
models.Add(item);
if (_config.IndexId == it.IndexId)
{
SelectedServer = item;
}
}
BlServers = true;
Servers.Clear();
Servers.AddRange(models);
// Update the ItemsSource before SelectedItem so a collection reset does not clear the tray selection.
SelectedServer = models.FirstOrDefault(it => it.ID == _config.IndexId) ?? new();
}
private void ServerSelectedChanged(bool c)