updateSubscription and try to re-select the last choice.

This commit is contained in:
JaredDC 2021-06-29 23:01:52 +08:00
parent 672eb4b365
commit 1d3b5452a5
2 changed files with 22 additions and 3 deletions

View file

@ -1316,9 +1316,28 @@ namespace v2rayN.Forms
private void tsbSubUpdate_Click(object sender, EventArgs e) 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);
} }
/// <summary> /// <summary>
/// the subscription update process /// the subscription update process
/// </summary> /// </summary>

View file

@ -14,7 +14,7 @@ namespace v2rayN.Handler
{ {
Action<bool, string> _updateFunc; Action<bool, string> _updateFunc;
private Config _config; private Config _config;
public bool updateSubscriptionProcessCompleted = false;
public event EventHandler<ResultEventArgs> AbsoluteCompleted; public event EventHandler<ResultEventArgs> AbsoluteCompleted;
public class ResultEventArgs : EventArgs public class ResultEventArgs : EventArgs