diff --git a/v2rayN/ServiceLib/Handler/Data/ConfigTextHandler.cs b/v2rayN/ServiceLib/Handler/Data/ConfigTextHandler.cs index 113f2e4e..1296efe8 100644 --- a/v2rayN/ServiceLib/Handler/Data/ConfigTextHandler.cs +++ b/v2rayN/ServiceLib/Handler/Data/ConfigTextHandler.cs @@ -306,6 +306,11 @@ public static class ConfigTextHandler #region DefaultServer + public static async Task ResetDefaultServer() + { + return await SetDefaultServerIndex(Config.IndexId); + } + /// /// Set the default server by its index ID /// Updates the configuration to use the specified server as default @@ -319,6 +324,7 @@ public static class ConfigTextHandler return -1; } + Config.PreIndexId = Config.IndexId; Config.IndexId = indexId; await SaveConfig(); diff --git a/v2rayN/ServiceLib/Handler/SubscriptionHandler.cs b/v2rayN/ServiceLib/Handler/SubscriptionHandler.cs index 7edf9377..8b347a77 100644 --- a/v2rayN/ServiceLib/Handler/SubscriptionHandler.cs +++ b/v2rayN/ServiceLib/Handler/SubscriptionHandler.cs @@ -21,6 +21,7 @@ public class SubscriptionHandler( return; } + await ConfigTextHandler.ResetDefaultServer(); var successCount = 0; foreach (var item in subItem) { diff --git a/v2rayN/ServiceLib/Models/Configs/Config.cs b/v2rayN/ServiceLib/Models/Configs/Config.cs index 61ef2e91..c77a95cd 100644 --- a/v2rayN/ServiceLib/Models/Configs/Config.cs +++ b/v2rayN/ServiceLib/Models/Configs/Config.cs @@ -4,6 +4,7 @@ public class Config { #region property + public string PreIndexId { get; set; } public string IndexId { get; set; } public string SubIndexId { get; set; } diff --git a/v2rayN/ServiceLib/ViewModels/MainWindowViewModel.cs b/v2rayN/ServiceLib/ViewModels/MainWindowViewModel.cs index 0c37c7c5..88181527 100644 --- a/v2rayN/ServiceLib/ViewModels/MainWindowViewModel.cs +++ b/v2rayN/ServiceLib/ViewModels/MainWindowViewModel.cs @@ -366,23 +366,12 @@ public partial class MainWindowViewModel : MyReactiveObject NoticeManager.Instance.SendMessageEx(msg); if (success) { - var indexIdOld = _config.IndexId; await RefreshServersDispatcherAsync(); - // If indexId changed or subIndexId is empty, directly reload. - if (indexIdOld != _config.IndexId || _config.SubIndexId.IsNullOrEmpty()) + if (_config.IndexId != _config.PreIndexId) { 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) {