mirror of
https://github.com/2dust/v2rayN.git
synced 2025-08-24 11:56:55 +00:00
updateSubscription and try to re-select the last choice.
This commit is contained in:
parent
672eb4b365
commit
a52092b363
3 changed files with 51 additions and 4 deletions
|
@ -1313,12 +1313,54 @@ namespace v2rayN.Forms
|
||||||
RefreshServers();
|
RefreshServers();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Reset to the previous selected.
|
||||||
|
/// </summary>
|
||||||
|
private int FindIndexByRemarks(string remarks)
|
||||||
|
{
|
||||||
|
for (int k = 0; k < config.vmess.Count; k++)
|
||||||
|
{
|
||||||
|
VmessItem item = config.vmess[k];
|
||||||
|
if (item.remarks.Equals(remarks))
|
||||||
|
{
|
||||||
|
return k;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (int k = 0; k < config.vmess.Count; k++)
|
||||||
|
{
|
||||||
|
VmessItem item = config.vmess[k];
|
||||||
|
if (item.remarks.Contains(remarks.Substring(0, 2)))
|
||||||
|
{
|
||||||
|
// 汉字也是占一个, 台湾 CHT [06]
|
||||||
|
return k;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
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>
|
||||||
|
|
|
@ -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
|
||||||
|
@ -212,6 +212,7 @@ namespace v2rayN.Handler
|
||||||
{
|
{
|
||||||
_updateFunc(false, $"{hashCode}{UIRes.I18N("MsgFailedImportSubscription")}");
|
_updateFunc(false, $"{hashCode}{UIRes.I18N("MsgFailedImportSubscription")}");
|
||||||
}
|
}
|
||||||
|
updateSubscriptionProcessCompleted = true;
|
||||||
_updateFunc(true, $"{hashCode}{UIRes.I18N("MsgUpdateSubscriptionEnd")}");
|
_updateFunc(true, $"{hashCode}{UIRes.I18N("MsgUpdateSubscriptionEnd")}");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
@ -498,6 +498,10 @@ del $(TargetDir)*.xml $(TargetDir)*.so $(TargetDir)*.dylib
|
||||||
if not "$(ConfigurationName)" == "Debug" del $(TargetDir)*.pdb</PostBuildEvent>
|
if not "$(ConfigurationName)" == "Debug" del $(TargetDir)*.pdb</PostBuildEvent>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<Import Project="..\packages\Grpc.Core.2.23.0\build\net45\Grpc.Core.targets" Condition="Exists('..\packages\Grpc.Core.2.23.0\build\net45\Grpc.Core.targets')" />
|
<Import Project="..\packages\Grpc.Core.2.23.0\build\net45\Grpc.Core.targets" Condition="Exists('..\packages\Grpc.Core.2.23.0\build\net45\Grpc.Core.targets')" />
|
||||||
|
<PropertyGroup>
|
||||||
|
<PreBuildEvent>TASKKILL /F /IM v2rayN.exe /T
|
||||||
|
set errolevel=0</PreBuildEvent>
|
||||||
|
</PropertyGroup>
|
||||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||||
Other similar extension points exist, see Microsoft.Common.targets.
|
Other similar extension points exist, see Microsoft.Common.targets.
|
||||||
<Target Name="BeforeBuild">
|
<Target Name="BeforeBuild">
|
||||||
|
|
Loading…
Reference in a new issue