mirror of
https://github.com/2dust/v2rayN.git
synced 2026-11-18 10:25:00 +03:00
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:
@@ -306,6 +306,11 @@ public static class ConfigTextHandler
|
||||
|
||||
#region DefaultServer
|
||||
|
||||
public static async Task<int> ResetDefaultServer()
|
||||
{
|
||||
return await SetDefaultServerIndex(Config.IndexId);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 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();
|
||||
|
||||
@@ -21,6 +21,7 @@ public class SubscriptionHandler(
|
||||
return;
|
||||
}
|
||||
|
||||
await ConfigTextHandler.ResetDefaultServer();
|
||||
var successCount = 0;
|
||||
foreach (var item in subItem)
|
||||
{
|
||||
|
||||
@@ -4,6 +4,7 @@ public class Config
|
||||
{
|
||||
#region property
|
||||
|
||||
public string PreIndexId { get; set; }
|
||||
public string IndexId { get; set; }
|
||||
public string SubIndexId { get; set; }
|
||||
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user