diff --git a/v2rayN/ServiceLib/Handler/ConfigHandler.cs b/v2rayN/ServiceLib/Handler/ConfigHandler.cs index a49f12f7..281db07d 100644 --- a/v2rayN/ServiceLib/Handler/ConfigHandler.cs +++ b/v2rayN/ServiceLib/Handler/ConfigHandler.cs @@ -1936,6 +1936,12 @@ public static class ConfigHandler await SQLiteHelper.Instance.DeleteAsync(item); await RemoveServersViaSubid(config, id, false); + if (item.Id == config.SubIndexId) + { + var subs = await AppManager.Instance.SubItems(); + config.SubIndexId = subs.LastOrDefault()?.Id; + } + return 0; } diff --git a/v2rayN/ServiceLib/ViewModels/ProfilesSelectViewModel.cs b/v2rayN/ServiceLib/ViewModels/ProfilesSelectViewModel.cs index b3810b52..a4d9b298 100644 --- a/v2rayN/ServiceLib/ViewModels/ProfilesSelectViewModel.cs +++ b/v2rayN/ServiceLib/ViewModels/ProfilesSelectViewModel.cs @@ -190,7 +190,7 @@ public class ProfilesSelectViewModel : MyReactiveObject } SelectedSub = (_config.SubIndexId.IsNotEmpty() ? SubItems.FirstOrDefault(t => t.Id == _config.SubIndexId) - : null) ?? SubItems.LastOrDefault(); + : null) ?? SubItems.FirstOrDefault(); } private async Task?> GetProfileItemsEx(string subid, string filter) diff --git a/v2rayN/ServiceLib/ViewModels/ProfilesViewModel.cs b/v2rayN/ServiceLib/ViewModels/ProfilesViewModel.cs index 7a127fa7..f44f52e3 100644 --- a/v2rayN/ServiceLib/ViewModels/ProfilesViewModel.cs +++ b/v2rayN/ServiceLib/ViewModels/ProfilesViewModel.cs @@ -393,7 +393,7 @@ public class ProfilesViewModel : MyReactiveObject } SelectedSub = (_config.SubIndexId.IsNotEmpty() ? SubItems.FirstOrDefault(t => t.Id == _config.SubIndexId) - : null) ?? SubItems.LastOrDefault(); + : null) ?? SubItems.FirstOrDefault(); } private async Task?> GetProfileItemsEx(string subid, string filter)