From 1d3b5452a5993d5d0f5025a97156c0f59381ab89 Mon Sep 17 00:00:00 2001 From: JaredDC Date: Tue, 29 Jun 2021 23:01:52 +0800 Subject: [PATCH] updateSubscription and try to re-select the last choice. --- v2rayN/v2rayN/Forms/MainForm.cs | 23 +++++++++++++++++++++-- v2rayN/v2rayN/Handler/UpdateHandle.cs | 2 +- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/v2rayN/v2rayN/Forms/MainForm.cs b/v2rayN/v2rayN/Forms/MainForm.cs index 56c63c23..e4927b45 100644 --- a/v2rayN/v2rayN/Forms/MainForm.cs +++ b/v2rayN/v2rayN/Forms/MainForm.cs @@ -1316,9 +1316,28 @@ namespace v2rayN.Forms private void tsbSubUpdate_Click(object sender, EventArgs e) { - UpdateSubscriptionProcess(); + VmessItem item = config.vmess[config.index]; + var remarks = item.remarks; + var handle = new UpdateHandle(); + void _updateUIAndReselect(bool success, string msg) + { + AppendText(false, msg); + if (success) + { + RefreshServers(); + } + if (handle.updateSubscriptionProcessCompleted) + { + // wait for above fxcking async program to complete + int index = FindIndexByRemarks(remarks); + SetDefaultServer(index); + AppendText(false, $"{UIRes.I18N("MsgUpdateSubscriptionEndReslectLast")}"); + RefreshServers(); + handle.updateSubscriptionProcessCompleted = false; + } + }; + handle.UpdateSubscriptionProcess(config, _updateUIAndReselect); } - /// /// the subscription update process /// diff --git a/v2rayN/v2rayN/Handler/UpdateHandle.cs b/v2rayN/v2rayN/Handler/UpdateHandle.cs index 2a35d676..d5814840 100644 --- a/v2rayN/v2rayN/Handler/UpdateHandle.cs +++ b/v2rayN/v2rayN/Handler/UpdateHandle.cs @@ -14,7 +14,7 @@ namespace v2rayN.Handler { Action _updateFunc; private Config _config; - + public bool updateSubscriptionProcessCompleted = false; public event EventHandler AbsoluteCompleted; public class ResultEventArgs : EventArgs