Reload after subscription updates only on change

Track the previous default server and reload when its ID changes during a subscription update.
This commit is contained in:
2dust
2026-11-18 14:36:29 +08:00
parent 562d289495
commit 109c7fd5b3
4 changed files with 9 additions and 12 deletions
@@ -306,6 +306,11 @@ public static class ConfigTextHandler
#region DefaultServer #region DefaultServer
public static async Task<int> ResetDefaultServer()
{
return await SetDefaultServerIndex(Config.IndexId);
}
/// <summary> /// <summary>
/// Set the default server by its index ID /// Set the default server by its index ID
/// Updates the configuration to use the specified server as default /// Updates the configuration to use the specified server as default
@@ -319,6 +324,7 @@ public static class ConfigTextHandler
return -1; return -1;
} }
Config.PreIndexId = Config.IndexId;
Config.IndexId = indexId; Config.IndexId = indexId;
await SaveConfig(); await SaveConfig();
@@ -21,6 +21,7 @@ public class SubscriptionHandler(
return; return;
} }
await ConfigTextHandler.ResetDefaultServer();
var successCount = 0; var successCount = 0;
foreach (var item in subItem) foreach (var item in subItem)
{ {
@@ -4,6 +4,7 @@ public class Config
{ {
#region property #region property
public string PreIndexId { get; set; }
public string IndexId { get; set; } public string IndexId { get; set; }
public string SubIndexId { get; set; } public string SubIndexId { get; set; }
@@ -366,23 +366,12 @@ public partial class MainWindowViewModel : MyReactiveObject
NoticeManager.Instance.SendMessageEx(msg); NoticeManager.Instance.SendMessageEx(msg);
if (success) if (success)
{ {
var indexIdOld = _config.IndexId;
await RefreshServersDispatcherAsync(); await RefreshServersDispatcherAsync();
// If indexId changed or subIndexId is empty, directly reload. if (_config.IndexId != _config.PreIndexId)
if (indexIdOld != _config.IndexId || _config.SubIndexId.IsNullOrEmpty())
{ {
await Reload(); await Reload();
} }
else
{
// The activity config belongs to the current group.
var profile = await ConfigDbQuery.GetProfileItem(_config.IndexId);
if (profile != null && profile.Subid == _config.SubIndexId)
{
await Reload();
}
}
if (_config.UiItem.EnableAutoAdjustMainLvColWidth) if (_config.UiItem.EnableAutoAdjustMainLvColWidth)
{ {