mirror of https://github.com/2dust/v2rayN
Refactor_updateView to add task
parent
b936c194e4
commit
b57cdd31bd
|
@ -5,7 +5,7 @@ namespace ServiceLib.Base
|
|||
public class MyReactiveObject : ReactiveObject
|
||||
{
|
||||
protected static Config? _config;
|
||||
protected Func<EViewAction, object?, bool>? _updateView;
|
||||
protected Func<EViewAction, object?, Task<bool>>? _updateView;
|
||||
protected NoticeHandler? _noticeHandler;
|
||||
}
|
||||
}
|
|
@ -15,7 +15,7 @@ namespace ServiceLib.ViewModels
|
|||
public ReactiveCommand<Unit, Unit> SaveServerCmd { get; }
|
||||
public bool IsModified { get; set; }
|
||||
|
||||
public AddServer2ViewModel(ProfileItem profileItem, Func<EViewAction, object?, bool>? updateView)
|
||||
public AddServer2ViewModel(ProfileItem profileItem, Func<EViewAction, object?, Task<bool>>? updateView)
|
||||
{
|
||||
_noticeHandler = Locator.Current.GetService<NoticeHandler>();
|
||||
_config = LazyConfig.Instance.Config;
|
||||
|
@ -30,9 +30,9 @@ namespace ServiceLib.ViewModels
|
|||
SelectedSource = JsonUtils.DeepCopy(profileItem);
|
||||
}
|
||||
|
||||
BrowseServerCmd = ReactiveCommand.Create(() =>
|
||||
BrowseServerCmd = ReactiveCommand.CreateFromTask(async () =>
|
||||
{
|
||||
_updateView?.Invoke(EViewAction.BrowseServer, null);
|
||||
await _updateView?.Invoke(EViewAction.BrowseServer, null);
|
||||
});
|
||||
|
||||
EditServerCmd = ReactiveCommand.Create(() =>
|
||||
|
@ -42,11 +42,11 @@ namespace ServiceLib.ViewModels
|
|||
|
||||
SaveServerCmd = ReactiveCommand.Create(() =>
|
||||
{
|
||||
SaveServer();
|
||||
SaveServerAsync();
|
||||
});
|
||||
}
|
||||
|
||||
private void SaveServer()
|
||||
private async Task SaveServerAsync()
|
||||
{
|
||||
string remarks = SelectedSource.remarks;
|
||||
if (Utils.IsNullOrEmpty(remarks))
|
||||
|
@ -64,7 +64,7 @@ namespace ServiceLib.ViewModels
|
|||
if (ConfigHandler.EditCustomServer(_config, SelectedSource) == 0)
|
||||
{
|
||||
_noticeHandler?.Enqueue(ResUI.OperationSuccess);
|
||||
_updateView?.Invoke(EViewAction.CloseWindow, null);
|
||||
await _updateView?.Invoke(EViewAction.CloseWindow, null);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -12,7 +12,7 @@ namespace ServiceLib.ViewModels
|
|||
|
||||
public ReactiveCommand<Unit, Unit> SaveCmd { get; }
|
||||
|
||||
public AddServerViewModel(ProfileItem profileItem, Func<EViewAction, object?, bool>? updateView)
|
||||
public AddServerViewModel(ProfileItem profileItem, Func<EViewAction, object?, Task<bool>>? updateView)
|
||||
{
|
||||
_config = LazyConfig.Instance.Config;
|
||||
_noticeHandler = Locator.Current.GetService<NoticeHandler>();
|
||||
|
@ -33,11 +33,11 @@ namespace ServiceLib.ViewModels
|
|||
|
||||
SaveCmd = ReactiveCommand.Create(() =>
|
||||
{
|
||||
SaveServer();
|
||||
SaveServerAsync();
|
||||
});
|
||||
}
|
||||
|
||||
private void SaveServer()
|
||||
private async Task SaveServerAsync()
|
||||
{
|
||||
if (Utils.IsNullOrEmpty(SelectedSource.remarks))
|
||||
{
|
||||
|
@ -83,7 +83,7 @@ namespace ServiceLib.ViewModels
|
|||
if (ConfigHandler.AddServer(_config, SelectedSource) == 0)
|
||||
{
|
||||
_noticeHandler?.Enqueue(ResUI.OperationSuccess);
|
||||
_updateView?.Invoke(EViewAction.CloseWindow, null);
|
||||
await _updateView?.Invoke(EViewAction.CloseWindow, null);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -25,7 +25,7 @@ namespace ServiceLib.ViewModels
|
|||
[Reactive]
|
||||
public bool AutoRefresh { get; set; }
|
||||
|
||||
public ClashConnectionsViewModel(Func<EViewAction, object?, bool>? updateView)
|
||||
public ClashConnectionsViewModel(Func<EViewAction, object?, Task<bool>>? updateView)
|
||||
{
|
||||
_config = LazyConfig.Instance.Config;
|
||||
_updateView = updateView;
|
||||
|
@ -99,14 +99,14 @@ namespace ServiceLib.ViewModels
|
|||
|
||||
private void GetClashConnections()
|
||||
{
|
||||
ClashApiHandler.Instance.GetClashConnections(_config, (it) =>
|
||||
ClashApiHandler.Instance.GetClashConnections(_config, async (it) =>
|
||||
{
|
||||
if (it == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_updateView?.Invoke(EViewAction.DispatcherRefreshConnections, it?.connections);
|
||||
await _updateView?.Invoke(EViewAction.DispatcherRefreshConnections, it?.connections);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -42,7 +42,7 @@ namespace ServiceLib.ViewModels
|
|||
[Reactive]
|
||||
public bool AutoRefresh { get; set; }
|
||||
|
||||
public ClashProxiesViewModel(Func<EViewAction, object?, bool>? updateView)
|
||||
public ClashProxiesViewModel(Func<EViewAction, object?, Task<bool>>? updateView)
|
||||
{
|
||||
_noticeHandler = Locator.Current.GetService<NoticeHandler>();
|
||||
_config = LazyConfig.Instance.Config;
|
||||
|
@ -167,7 +167,7 @@ namespace ServiceLib.ViewModels
|
|||
|
||||
private void GetClashProxies(bool refreshUI)
|
||||
{
|
||||
ClashApiHandler.Instance.GetClashProxies(_config, (it, it2) =>
|
||||
ClashApiHandler.Instance.GetClashProxies(_config, async (it, it2) =>
|
||||
{
|
||||
//UpdateHandler(false, "Refresh Clash Proxies");
|
||||
_proxies = it?.proxies;
|
||||
|
@ -179,7 +179,7 @@ namespace ServiceLib.ViewModels
|
|||
}
|
||||
if (refreshUI)
|
||||
{
|
||||
_updateView?.Invoke(EViewAction.DispatcherRefreshProxyGroups, null);
|
||||
await _updateView?.Invoke(EViewAction.DispatcherRefreshProxyGroups, null);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -386,7 +386,7 @@ namespace ServiceLib.ViewModels
|
|||
{
|
||||
//UpdateHandler(false, "Clash Proxies Latency Test");
|
||||
|
||||
ClashApiHandler.Instance.ClashProxiesDelayTest(blAll, _proxyDetails.ToList(), (item, result) =>
|
||||
ClashApiHandler.Instance.ClashProxiesDelayTest(blAll, _proxyDetails.ToList(), async (item, result) =>
|
||||
{
|
||||
if (item == null)
|
||||
{
|
||||
|
@ -398,7 +398,7 @@ namespace ServiceLib.ViewModels
|
|||
return;
|
||||
}
|
||||
|
||||
_updateView?.Invoke(EViewAction.DispatcherProxiesDelayTest, new SpeedTestResult() { IndexId = item.name, Delay = result });
|
||||
await _updateView?.Invoke(EViewAction.DispatcherProxiesDelayTest, new SpeedTestResult() { IndexId = item.name, Delay = result });
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@ namespace ServiceLib.ViewModels
|
|||
public ReactiveCommand<Unit, Unit> ImportDefConfig4V2rayCmd { get; }
|
||||
public ReactiveCommand<Unit, Unit> ImportDefConfig4SingboxCmd { get; }
|
||||
|
||||
public DNSSettingViewModel(Func<EViewAction, object?, bool>? updateView)
|
||||
public DNSSettingViewModel(Func<EViewAction, object?, Task<bool>>? updateView)
|
||||
{
|
||||
_config = LazyConfig.Instance.Config;
|
||||
_noticeHandler = Locator.Current.GetService<NoticeHandler>();
|
||||
|
@ -41,7 +41,7 @@ namespace ServiceLib.ViewModels
|
|||
|
||||
SaveCmd = ReactiveCommand.Create(() =>
|
||||
{
|
||||
SaveSetting();
|
||||
SaveSettingAsync();
|
||||
});
|
||||
|
||||
ImportDefConfig4V2rayCmd = ReactiveCommand.Create(() =>
|
||||
|
@ -56,7 +56,7 @@ namespace ServiceLib.ViewModels
|
|||
});
|
||||
}
|
||||
|
||||
private void SaveSetting()
|
||||
private async Task SaveSettingAsync()
|
||||
{
|
||||
if (!Utils.IsNullOrEmpty(normalDNS))
|
||||
{
|
||||
|
@ -107,7 +107,7 @@ namespace ServiceLib.ViewModels
|
|||
ConfigHandler.SaveDNSItems(_config, item2);
|
||||
|
||||
_noticeHandler?.Enqueue(ResUI.OperationSuccess);
|
||||
_updateView?.Invoke(EViewAction.CloseWindow, null);
|
||||
await _updateView?.Invoke(EViewAction.CloseWindow, null);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -152,13 +152,13 @@ namespace ServiceLib.ViewModels
|
|||
|
||||
#region Init
|
||||
|
||||
public MainWindowViewModel(Func<EViewAction, object?, bool>? updateView)
|
||||
public MainWindowViewModel(Func<EViewAction, object?, Task<bool>>? updateView)
|
||||
{
|
||||
_config = LazyConfig.Instance.Config;
|
||||
_noticeHandler = Locator.Current.GetService<NoticeHandler>();
|
||||
_updateView = updateView;
|
||||
|
||||
MessageBus.Current.Listen<string>(Global.CommandRefreshProfiles).Subscribe(x => _updateView?.Invoke(EViewAction.DispatcherRefreshServersBiz, null));
|
||||
MessageBus.Current.Listen<string>(Global.CommandRefreshProfiles).Subscribe(async x => await _updateView?.Invoke(EViewAction.DispatcherRefreshServersBiz, null));
|
||||
|
||||
SelectedRouting = new();
|
||||
SelectedServer = new();
|
||||
|
@ -170,7 +170,7 @@ namespace ServiceLib.ViewModels
|
|||
this.WhenAnyValue(
|
||||
x => x.SelectedRouting,
|
||||
y => y != null && !y.remarks.IsNullOrEmpty())
|
||||
.Subscribe(c => RoutingSelectedChanged(c));
|
||||
.Subscribe(c => RoutingSelectedChangedAsync(c));
|
||||
|
||||
this.WhenAnyValue(
|
||||
x => x.SelectedServer,
|
||||
|
@ -191,57 +191,57 @@ namespace ServiceLib.ViewModels
|
|||
//servers
|
||||
AddVmessServerCmd = ReactiveCommand.Create(() =>
|
||||
{
|
||||
AddServer(true, EConfigType.VMess);
|
||||
AddServerAsync(true, EConfigType.VMess);
|
||||
});
|
||||
AddVlessServerCmd = ReactiveCommand.Create(() =>
|
||||
{
|
||||
AddServer(true, EConfigType.VLESS);
|
||||
AddServerAsync(true, EConfigType.VLESS);
|
||||
});
|
||||
AddShadowsocksServerCmd = ReactiveCommand.Create(() =>
|
||||
{
|
||||
AddServer(true, EConfigType.Shadowsocks);
|
||||
AddServerAsync(true, EConfigType.Shadowsocks);
|
||||
});
|
||||
AddSocksServerCmd = ReactiveCommand.Create(() =>
|
||||
{
|
||||
AddServer(true, EConfigType.Socks);
|
||||
AddServerAsync(true, EConfigType.Socks);
|
||||
});
|
||||
AddHttpServerCmd = ReactiveCommand.Create(() =>
|
||||
{
|
||||
AddServer(true, EConfigType.Http);
|
||||
AddServerAsync(true, EConfigType.Http);
|
||||
});
|
||||
AddTrojanServerCmd = ReactiveCommand.Create(() =>
|
||||
{
|
||||
AddServer(true, EConfigType.Trojan);
|
||||
AddServerAsync(true, EConfigType.Trojan);
|
||||
});
|
||||
AddHysteria2ServerCmd = ReactiveCommand.Create(() =>
|
||||
{
|
||||
AddServer(true, EConfigType.Hysteria2);
|
||||
AddServerAsync(true, EConfigType.Hysteria2);
|
||||
});
|
||||
AddTuicServerCmd = ReactiveCommand.Create(() =>
|
||||
{
|
||||
AddServer(true, EConfigType.Tuic);
|
||||
AddServerAsync(true, EConfigType.Tuic);
|
||||
});
|
||||
AddWireguardServerCmd = ReactiveCommand.Create(() =>
|
||||
{
|
||||
AddServer(true, EConfigType.Wireguard);
|
||||
AddServerAsync(true, EConfigType.Wireguard);
|
||||
});
|
||||
AddCustomServerCmd = ReactiveCommand.Create(() =>
|
||||
{
|
||||
AddServer(true, EConfigType.Custom);
|
||||
AddServerAsync(true, EConfigType.Custom);
|
||||
});
|
||||
AddServerViaClipboardCmd = ReactiveCommand.Create(() =>
|
||||
{
|
||||
AddServerViaClipboard(null);
|
||||
AddServerViaClipboardAsync(null);
|
||||
});
|
||||
AddServerViaScanCmd = ReactiveCommand.Create(() =>
|
||||
AddServerViaScanCmd = ReactiveCommand.CreateFromTask(async () =>
|
||||
{
|
||||
_updateView?.Invoke(EViewAction.ScanScreenTask, null);
|
||||
await _updateView?.Invoke(EViewAction.ScanScreenTask, null);
|
||||
});
|
||||
|
||||
//Subscription
|
||||
SubSettingCmd = ReactiveCommand.Create(() =>
|
||||
{
|
||||
SubSetting();
|
||||
SubSettingAsync();
|
||||
});
|
||||
|
||||
SubUpdateCmd = ReactiveCommand.Create(() =>
|
||||
|
@ -264,19 +264,19 @@ namespace ServiceLib.ViewModels
|
|||
//Setting
|
||||
OptionSettingCmd = ReactiveCommand.Create(() =>
|
||||
{
|
||||
OptionSetting();
|
||||
OptionSettingAsync();
|
||||
});
|
||||
RoutingSettingCmd = ReactiveCommand.Create(() =>
|
||||
{
|
||||
RoutingSetting();
|
||||
RoutingSettingAsync();
|
||||
});
|
||||
DNSSettingCmd = ReactiveCommand.Create(() =>
|
||||
{
|
||||
DNSSetting();
|
||||
DNSSettingAsync();
|
||||
});
|
||||
GlobalHotkeySettingCmd = ReactiveCommand.Create(() =>
|
||||
GlobalHotkeySettingCmd = ReactiveCommand.CreateFromTask(async () =>
|
||||
{
|
||||
if (_updateView?.Invoke(EViewAction.GlobalHotkeySettingWindow, null) == true)
|
||||
if (await _updateView?.Invoke(EViewAction.GlobalHotkeySettingWindow, null) == true)
|
||||
{
|
||||
_noticeHandler?.Enqueue(ResUI.OperationSuccess);
|
||||
}
|
||||
|
@ -322,9 +322,9 @@ namespace ServiceLib.ViewModels
|
|||
Reload();
|
||||
});
|
||||
|
||||
NotifyLeftClickCmd = ReactiveCommand.Create(() =>
|
||||
NotifyLeftClickCmd = ReactiveCommand.CreateFromTask(async () =>
|
||||
{
|
||||
_updateView?.Invoke(EViewAction.ShowHideWindow, null);
|
||||
await _updateView?.Invoke(EViewAction.ShowHideWindow, null);
|
||||
});
|
||||
|
||||
//System proxy
|
||||
|
@ -369,7 +369,7 @@ namespace ServiceLib.ViewModels
|
|||
//RefreshServers();
|
||||
|
||||
Reload();
|
||||
ChangeSystemProxyStatus(_config.systemProxyItem.sysProxyType, true);
|
||||
ChangeSystemProxyStatusAsync(_config.systemProxyItem.sysProxyType, true);
|
||||
}
|
||||
|
||||
#endregion Init
|
||||
|
@ -402,7 +402,7 @@ namespace ServiceLib.ViewModels
|
|||
}
|
||||
if (_config.uiItem.enableAutoAdjustMainLvColWidth)
|
||||
{
|
||||
Locator.Current.GetService<ProfilesViewModel>()?.AutofitColumnWidth();
|
||||
Locator.Current.GetService<ProfilesViewModel>()?.AutofitColumnWidthAsync();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -434,13 +434,13 @@ namespace ServiceLib.ViewModels
|
|||
}
|
||||
}
|
||||
|
||||
public void MyAppExit(bool blWindowsShutDown)
|
||||
public async Task MyAppExitAsync(bool blWindowsShutDown)
|
||||
{
|
||||
try
|
||||
{
|
||||
Logging.SaveLog("MyAppExit Begin");
|
||||
//if (blWindowsShutDown)
|
||||
_updateView?.Invoke(EViewAction.UpdateSysProxy, true);
|
||||
await _updateView?.Invoke(EViewAction.UpdateSysProxy, true);
|
||||
|
||||
ConfigHandler.SaveConfig(_config);
|
||||
ProfileExHandler.Instance.SaveTo();
|
||||
|
@ -453,7 +453,7 @@ namespace ServiceLib.ViewModels
|
|||
catch { }
|
||||
finally
|
||||
{
|
||||
_updateView?.Invoke(EViewAction.Shutdown, null);
|
||||
await _updateView?.Invoke(EViewAction.Shutdown, null);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -519,7 +519,7 @@ namespace ServiceLib.ViewModels
|
|||
|
||||
#region Add Servers
|
||||
|
||||
public void AddServer(bool blNew, EConfigType eConfigType)
|
||||
public async Task AddServerAsync(bool blNew, EConfigType eConfigType)
|
||||
{
|
||||
ProfileItem item = new()
|
||||
{
|
||||
|
@ -531,11 +531,11 @@ namespace ServiceLib.ViewModels
|
|||
bool? ret = false;
|
||||
if (eConfigType == EConfigType.Custom)
|
||||
{
|
||||
ret = _updateView?.Invoke(EViewAction.AddServer2Window, item);
|
||||
ret = await _updateView?.Invoke(EViewAction.AddServer2Window, item);
|
||||
}
|
||||
else
|
||||
{
|
||||
ret = _updateView?.Invoke(EViewAction.AddServerWindow, item);
|
||||
ret = await _updateView?.Invoke(EViewAction.AddServerWindow, item);
|
||||
}
|
||||
if (ret == true)
|
||||
{
|
||||
|
@ -547,11 +547,11 @@ namespace ServiceLib.ViewModels
|
|||
}
|
||||
}
|
||||
|
||||
public void AddServerViaClipboard(string? clipboardData)
|
||||
public async Task AddServerViaClipboardAsync(string? clipboardData)
|
||||
{
|
||||
if (clipboardData == null)
|
||||
{
|
||||
_updateView?.Invoke(EViewAction.AddServerViaClipboard, null);
|
||||
await _updateView?.Invoke(EViewAction.AddServerViaClipboard, null);
|
||||
return;
|
||||
}
|
||||
int ret = ConfigHandler.AddBatchServers(_config, clipboardData, _config.subIndexId, false);
|
||||
|
@ -629,7 +629,7 @@ namespace ServiceLib.ViewModels
|
|||
{
|
||||
return;
|
||||
}
|
||||
(new UpdateHandler()).RunAvailabilityCheck((bool success, string msg) =>
|
||||
(new UpdateHandler()).RunAvailabilityCheck(async (bool success, string msg) =>
|
||||
{
|
||||
_noticeHandler?.SendMessage(msg, true);
|
||||
|
||||
|
@ -637,7 +637,7 @@ namespace ServiceLib.ViewModels
|
|||
{
|
||||
return;
|
||||
}
|
||||
_updateView?.Invoke(EViewAction.DispatcherServerAvailability, msg);
|
||||
await _updateView?.Invoke(EViewAction.DispatcherServerAvailability, msg);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -650,9 +650,9 @@ namespace ServiceLib.ViewModels
|
|||
|
||||
#region Subscription
|
||||
|
||||
private void SubSetting()
|
||||
private async Task SubSettingAsync()
|
||||
{
|
||||
if (_updateView?.Invoke(EViewAction.SubSettingWindow, null) == true)
|
||||
if (await _updateView?.Invoke(EViewAction.SubSettingWindow, null) == true)
|
||||
{
|
||||
RefreshSubscriptions();
|
||||
}
|
||||
|
@ -667,9 +667,9 @@ namespace ServiceLib.ViewModels
|
|||
|
||||
#region Setting
|
||||
|
||||
private void OptionSetting()
|
||||
private async Task OptionSettingAsync()
|
||||
{
|
||||
var ret = _updateView?.Invoke(EViewAction.OptionSettingWindow, null);
|
||||
var ret = await _updateView?.Invoke(EViewAction.OptionSettingWindow, null);
|
||||
if (ret == true)
|
||||
{
|
||||
//RefreshServers();
|
||||
|
@ -677,9 +677,9 @@ namespace ServiceLib.ViewModels
|
|||
}
|
||||
}
|
||||
|
||||
private void RoutingSetting()
|
||||
private async Task RoutingSettingAsync()
|
||||
{
|
||||
var ret = _updateView?.Invoke(EViewAction.RoutingSettingWindow, null);
|
||||
var ret = await _updateView?.Invoke(EViewAction.RoutingSettingWindow, null);
|
||||
if (ret == true)
|
||||
{
|
||||
ConfigHandler.InitBuiltinRouting(_config);
|
||||
|
@ -689,9 +689,9 @@ namespace ServiceLib.ViewModels
|
|||
}
|
||||
}
|
||||
|
||||
private void DNSSetting()
|
||||
private async Task DNSSettingAsync()
|
||||
{
|
||||
var ret = _updateView?.Invoke(EViewAction.DNSSettingWindow, null);
|
||||
var ret = await _updateView?.Invoke(EViewAction.DNSSettingWindow, null);
|
||||
if (ret == true)
|
||||
{
|
||||
Reload();
|
||||
|
@ -711,7 +711,7 @@ namespace ServiceLib.ViewModels
|
|||
try
|
||||
{
|
||||
Process.Start(startInfo);
|
||||
MyAppExit(false);
|
||||
MyAppExitAsync(false);
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
|
@ -742,7 +742,7 @@ namespace ServiceLib.ViewModels
|
|||
process.Start();
|
||||
if (process.Id > 0)
|
||||
{
|
||||
MyAppExit(false);
|
||||
MyAppExitAsync(false);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
@ -796,17 +796,17 @@ namespace ServiceLib.ViewModels
|
|||
{
|
||||
BlReloadEnabled = false;
|
||||
|
||||
LoadCore().ContinueWith(task =>
|
||||
LoadCore().ContinueWith(async task =>
|
||||
{
|
||||
TestServerAvailability();
|
||||
|
||||
_updateView?.Invoke(EViewAction.DispatcherReload, null);
|
||||
await _updateView?.Invoke(EViewAction.DispatcherReload, null);
|
||||
});
|
||||
}
|
||||
|
||||
public void ReloadResult()
|
||||
{
|
||||
ChangeSystemProxyStatus(_config.systemProxyItem.sysProxyType, false);
|
||||
ChangeSystemProxyStatusAsync(_config.systemProxyItem.sysProxyType, false);
|
||||
BlReloadEnabled = true;
|
||||
ShowClashUI = _config.IsRunningCore(ECoreType.clash);
|
||||
if (ShowClashUI)
|
||||
|
@ -835,7 +835,7 @@ namespace ServiceLib.ViewModels
|
|||
{
|
||||
ConfigHandler.SaveConfig(_config, false);
|
||||
|
||||
ChangeSystemProxyStatus(ESysProxyType.ForcedClear, false);
|
||||
ChangeSystemProxyStatusAsync(ESysProxyType.ForcedClear, false);
|
||||
|
||||
_coreHandler.CoreStop();
|
||||
}
|
||||
|
@ -851,15 +851,15 @@ namespace ServiceLib.ViewModels
|
|||
return;
|
||||
}
|
||||
_config.systemProxyItem.sysProxyType = type;
|
||||
ChangeSystemProxyStatus(type, true);
|
||||
ChangeSystemProxyStatusAsync(type, true);
|
||||
|
||||
SystemProxySelected = (int)_config.systemProxyItem.sysProxyType;
|
||||
ConfigHandler.SaveConfig(_config, false);
|
||||
}
|
||||
|
||||
private void ChangeSystemProxyStatus(ESysProxyType type, bool blChange)
|
||||
private async Task ChangeSystemProxyStatusAsync(ESysProxyType type, bool blChange)
|
||||
{
|
||||
_updateView?.Invoke(EViewAction.UpdateSysProxy, _config.tunModeItem.enableTun ? true : false);
|
||||
await _updateView?.Invoke(EViewAction.UpdateSysProxy, _config.tunModeItem.enableTun ? true : false);
|
||||
_noticeHandler?.SendMessage($"{ResUI.TipChangeSystemProxy} - {_config.systemProxyItem.sysProxyType.ToString()}", true);
|
||||
|
||||
BlSystemProxyClear = (type == ESysProxyType.ForcedClear);
|
||||
|
@ -871,7 +871,7 @@ namespace ServiceLib.ViewModels
|
|||
|
||||
if (blChange)
|
||||
{
|
||||
_updateView?.Invoke(EViewAction.DispatcherRefreshIcon, null);
|
||||
await _updateView?.Invoke(EViewAction.DispatcherRefreshIcon, null);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -896,7 +896,7 @@ namespace ServiceLib.ViewModels
|
|||
}
|
||||
}
|
||||
|
||||
private void RoutingSelectedChanged(bool c)
|
||||
private async Task RoutingSelectedChangedAsync(bool c)
|
||||
{
|
||||
if (!c)
|
||||
{
|
||||
|
@ -922,7 +922,7 @@ namespace ServiceLib.ViewModels
|
|||
{
|
||||
_noticeHandler?.SendMessage(ResUI.TipChangeRouting, true);
|
||||
Reload();
|
||||
_updateView?.Invoke(EViewAction.DispatcherRefreshIcon, null);
|
||||
await _updateView?.Invoke(EViewAction.DispatcherRefreshIcon, null);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1001,9 +1001,9 @@ namespace ServiceLib.ViewModels
|
|||
{
|
||||
Observable.Range(1, 1)
|
||||
.Delay(TimeSpan.FromSeconds(1))
|
||||
.Subscribe(x =>
|
||||
.Subscribe(async x =>
|
||||
{
|
||||
_updateView?.Invoke(EViewAction.ShowHideWindow, false);
|
||||
await _updateView?.Invoke(EViewAction.ShowHideWindow, false);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -100,7 +100,7 @@ namespace ServiceLib.ViewModels
|
|||
|
||||
public ReactiveCommand<Unit, Unit> SaveCmd { get; }
|
||||
|
||||
public OptionSettingViewModel(Func<EViewAction, object?, bool>? updateView)
|
||||
public OptionSettingViewModel(Func<EViewAction, object?, Task<bool>>? updateView)
|
||||
{
|
||||
_config = LazyConfig.Instance.Config;
|
||||
_noticeHandler = Locator.Current.GetService<NoticeHandler>();
|
||||
|
@ -190,7 +190,7 @@ namespace ServiceLib.ViewModels
|
|||
|
||||
SaveCmd = ReactiveCommand.Create(() =>
|
||||
{
|
||||
SaveSetting();
|
||||
SaveSettingAsync();
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -246,7 +246,7 @@ namespace ServiceLib.ViewModels
|
|||
});
|
||||
}
|
||||
|
||||
private void SaveSetting()
|
||||
private async Task SaveSettingAsync()
|
||||
{
|
||||
if (Utils.IsNullOrEmpty(localPort.ToString()) || !Utils.IsNumeric(localPort.ToString())
|
||||
|| localPort <= 0 || localPort >= Global.MaxPort)
|
||||
|
@ -343,7 +343,7 @@ namespace ServiceLib.ViewModels
|
|||
{
|
||||
_noticeHandler?.Enqueue(ResUI.OperationSuccess);
|
||||
}
|
||||
_updateView?.Invoke(EViewAction.CloseWindow, null);
|
||||
await _updateView?.Invoke(EViewAction.CloseWindow, null);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -95,13 +95,13 @@ namespace ServiceLib.ViewModels
|
|||
|
||||
#region Init
|
||||
|
||||
public ProfilesViewModel(Func<EViewAction, object?, bool>? updateView)
|
||||
public ProfilesViewModel(Func<EViewAction, object?, Task<bool>>? updateView)
|
||||
{
|
||||
_config = LazyConfig.Instance.Config;
|
||||
_noticeHandler = Locator.Current.GetService<NoticeHandler>();
|
||||
_updateView = updateView;
|
||||
|
||||
MessageBus.Current.Listen<string>(Global.CommandRefreshProfiles).Subscribe(x => _updateView?.Invoke(EViewAction.DispatcherRefreshServersBiz, null));
|
||||
MessageBus.Current.Listen<string>(Global.CommandRefreshProfiles).Subscribe(async x => await _updateView?.Invoke(EViewAction.DispatcherRefreshServersBiz, null));
|
||||
|
||||
SelectedProfile = new();
|
||||
SelectedSub = new();
|
||||
|
@ -120,7 +120,7 @@ namespace ServiceLib.ViewModels
|
|||
this.WhenAnyValue(
|
||||
x => x.SelectedSub,
|
||||
y => y != null && !y.remarks.IsNullOrEmpty() && _config.subIndexId != y.id)
|
||||
.Subscribe(c => SubSelectedChanged(c));
|
||||
.Subscribe(c => SubSelectedChangedAsync(c));
|
||||
this.WhenAnyValue(
|
||||
x => x.SelectedMoveToGroup,
|
||||
y => y != null && !y.remarks.IsNullOrEmpty())
|
||||
|
@ -139,11 +139,11 @@ namespace ServiceLib.ViewModels
|
|||
//servers delete
|
||||
EditServerCmd = ReactiveCommand.Create(() =>
|
||||
{
|
||||
EditServer(EConfigType.Custom);
|
||||
EditServerAsync(EConfigType.Custom);
|
||||
}, canEditRemove);
|
||||
RemoveServerCmd = ReactiveCommand.Create(() =>
|
||||
{
|
||||
RemoveServer();
|
||||
RemoveServerAsync();
|
||||
}, canEditRemove);
|
||||
RemoveDuplicateServerCmd = ReactiveCommand.Create(() =>
|
||||
{
|
||||
|
@ -159,7 +159,7 @@ namespace ServiceLib.ViewModels
|
|||
}, canEditRemove);
|
||||
ShareServerCmd = ReactiveCommand.Create(() =>
|
||||
{
|
||||
ShareServer();
|
||||
ShareServerAsync();
|
||||
}, canEditRemove);
|
||||
SetDefaultMultipleServerCmd = ReactiveCommand.Create(() =>
|
||||
{
|
||||
|
@ -212,29 +212,29 @@ namespace ServiceLib.ViewModels
|
|||
//servers export
|
||||
Export2ClientConfigCmd = ReactiveCommand.Create(() =>
|
||||
{
|
||||
Export2ClientConfig(false);
|
||||
Export2ClientConfigAsync(false);
|
||||
}, canEditRemove);
|
||||
Export2ClientConfigClipboardCmd = ReactiveCommand.Create(() =>
|
||||
{
|
||||
Export2ClientConfig(true);
|
||||
Export2ClientConfigAsync(true);
|
||||
}, canEditRemove);
|
||||
Export2ShareUrlCmd = ReactiveCommand.Create(() =>
|
||||
{
|
||||
Export2ShareUrl(false);
|
||||
Export2ShareUrlAsync(false);
|
||||
}, canEditRemove);
|
||||
Export2ShareUrlBase64Cmd = ReactiveCommand.Create(() =>
|
||||
{
|
||||
Export2ShareUrl(true);
|
||||
Export2ShareUrlAsync(true);
|
||||
}, canEditRemove);
|
||||
|
||||
//Subscription
|
||||
AddSubCmd = ReactiveCommand.Create(() =>
|
||||
{
|
||||
EditSub(true);
|
||||
EditSubAsync(true);
|
||||
});
|
||||
EditSubCmd = ReactiveCommand.Create(() =>
|
||||
{
|
||||
EditSub(false);
|
||||
EditSubAsync(false);
|
||||
});
|
||||
|
||||
#endregion WhenAnyValue && ReactiveCommand
|
||||
|
@ -308,16 +308,16 @@ namespace ServiceLib.ViewModels
|
|||
}
|
||||
}
|
||||
|
||||
public void AutofitColumnWidth()
|
||||
public async Task AutofitColumnWidthAsync()
|
||||
{
|
||||
_updateView?.Invoke(EViewAction.AdjustMainLvColWidth, null);
|
||||
await _updateView?.Invoke(EViewAction.AdjustMainLvColWidth, null);
|
||||
}
|
||||
|
||||
#endregion Actions
|
||||
|
||||
#region Servers && Groups
|
||||
|
||||
private void SubSelectedChanged(bool c)
|
||||
private async Task SubSelectedChangedAsync(bool c)
|
||||
{
|
||||
if (!c)
|
||||
{
|
||||
|
@ -327,7 +327,7 @@ namespace ServiceLib.ViewModels
|
|||
|
||||
RefreshServers();
|
||||
|
||||
_updateView?.Invoke(EViewAction.ProfilesFocus, null);
|
||||
await _updateView?.Invoke(EViewAction.ProfilesFocus, null);
|
||||
}
|
||||
|
||||
private void ServerFilterChanged(bool c)
|
||||
|
@ -420,7 +420,7 @@ namespace ServiceLib.ViewModels
|
|||
return 0;
|
||||
}
|
||||
|
||||
public void EditServer(EConfigType eConfigType)
|
||||
public async Task EditServerAsync(EConfigType eConfigType)
|
||||
{
|
||||
if (Utils.IsNullOrEmpty(SelectedProfile?.indexId))
|
||||
{
|
||||
|
@ -437,11 +437,11 @@ namespace ServiceLib.ViewModels
|
|||
bool? ret = false;
|
||||
if (eConfigType == EConfigType.Custom)
|
||||
{
|
||||
ret = _updateView?.Invoke(EViewAction.AddServer2Window, item);
|
||||
ret = await _updateView?.Invoke(EViewAction.AddServer2Window, item);
|
||||
}
|
||||
else
|
||||
{
|
||||
ret = _updateView?.Invoke(EViewAction.AddServerWindow, item);
|
||||
ret = await _updateView?.Invoke(EViewAction.AddServerWindow, item);
|
||||
}
|
||||
if (ret == true)
|
||||
{
|
||||
|
@ -453,13 +453,13 @@ namespace ServiceLib.ViewModels
|
|||
}
|
||||
}
|
||||
|
||||
public void RemoveServer()
|
||||
public async Task RemoveServerAsync()
|
||||
{
|
||||
if (GetProfileItems(out List<ProfileItem> lstSelecteds, true) < 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (_updateView?.Invoke(EViewAction.ShowYesNo, null) == false)
|
||||
if (await _updateView?.Invoke(EViewAction.ShowYesNo, null) == false)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
@ -546,7 +546,7 @@ namespace ServiceLib.ViewModels
|
|||
SetDefaultServer(SelectedServer.ID);
|
||||
}
|
||||
|
||||
public void ShareServer()
|
||||
public async Task ShareServerAsync()
|
||||
{
|
||||
var item = LazyConfig.Instance.GetProfileItem(SelectedProfile.indexId);
|
||||
if (item is null)
|
||||
|
@ -560,7 +560,7 @@ namespace ServiceLib.ViewModels
|
|||
return;
|
||||
}
|
||||
|
||||
_updateView?.Invoke(EViewAction.ShareServer, url);
|
||||
await _updateView?.Invoke(EViewAction.ShareServer, url);
|
||||
}
|
||||
|
||||
private void SetDefaultMultipleServer(ECoreType coreType)
|
||||
|
@ -679,7 +679,7 @@ namespace ServiceLib.ViewModels
|
|||
_speedtestHandler?.ExitLoop();
|
||||
}
|
||||
|
||||
private void Export2ClientConfig(bool blClipboard)
|
||||
private async Task Export2ClientConfigAsync(bool blClipboard)
|
||||
{
|
||||
var item = LazyConfig.Instance.GetProfileItem(SelectedProfile.indexId);
|
||||
if (item is null)
|
||||
|
@ -695,13 +695,13 @@ namespace ServiceLib.ViewModels
|
|||
}
|
||||
else
|
||||
{
|
||||
_updateView?.Invoke(EViewAction.SetClipboardData, content);
|
||||
await _updateView?.Invoke(EViewAction.SetClipboardData, content);
|
||||
_noticeHandler?.SendMessage(ResUI.OperationSuccess);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_updateView?.Invoke(EViewAction.SaveFileDialog, item);
|
||||
await _updateView?.Invoke(EViewAction.SaveFileDialog, item);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -722,7 +722,7 @@ namespace ServiceLib.ViewModels
|
|||
}
|
||||
}
|
||||
|
||||
public void Export2ShareUrl(bool blEncode)
|
||||
public async Task Export2ShareUrlAsync(bool blEncode)
|
||||
{
|
||||
if (GetProfileItems(out List<ProfileItem> lstSelecteds, true) < 0)
|
||||
{
|
||||
|
@ -744,11 +744,11 @@ namespace ServiceLib.ViewModels
|
|||
{
|
||||
if (blEncode)
|
||||
{
|
||||
_updateView?.Invoke(EViewAction.SetClipboardData, Utils.Base64Encode(sb.ToString()));
|
||||
await _updateView?.Invoke(EViewAction.SetClipboardData, Utils.Base64Encode(sb.ToString()));
|
||||
}
|
||||
else
|
||||
{
|
||||
_updateView?.Invoke(EViewAction.SetClipboardData, sb.ToString());
|
||||
await _updateView?.Invoke(EViewAction.SetClipboardData, sb.ToString());
|
||||
}
|
||||
_noticeHandler?.SendMessage(ResUI.BatchExportURLSuccessfully);
|
||||
}
|
||||
|
@ -758,7 +758,7 @@ namespace ServiceLib.ViewModels
|
|||
|
||||
#region Subscription
|
||||
|
||||
private void EditSub(bool blNew)
|
||||
private async Task EditSubAsync(bool blNew)
|
||||
{
|
||||
SubItem item;
|
||||
if (blNew)
|
||||
|
@ -773,10 +773,10 @@ namespace ServiceLib.ViewModels
|
|||
return;
|
||||
}
|
||||
}
|
||||
if (_updateView?.Invoke(EViewAction.SubEditWindow, item) == true)
|
||||
if (await _updateView?.Invoke(EViewAction.SubEditWindow, item) == true)
|
||||
{
|
||||
RefreshSubscriptions();
|
||||
SubSelectedChanged(true);
|
||||
SubSelectedChangedAsync(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -27,7 +27,7 @@ namespace ServiceLib.ViewModels
|
|||
|
||||
public ReactiveCommand<Unit, Unit> SaveCmd { get; }
|
||||
|
||||
public RoutingRuleDetailsViewModel(RulesItem rulesItem, Func<EViewAction, object?, bool>? updateView)
|
||||
public RoutingRuleDetailsViewModel(RulesItem rulesItem, Func<EViewAction, object?, Task<bool>>? updateView)
|
||||
{
|
||||
_config = LazyConfig.Instance.Config;
|
||||
_noticeHandler = Locator.Current.GetService<NoticeHandler>();
|
||||
|
@ -51,11 +51,11 @@ namespace ServiceLib.ViewModels
|
|||
|
||||
SaveCmd = ReactiveCommand.Create(() =>
|
||||
{
|
||||
SaveRules();
|
||||
SaveRulesAsync();
|
||||
});
|
||||
}
|
||||
|
||||
private void SaveRules()
|
||||
private async Task SaveRulesAsync()
|
||||
{
|
||||
Domain = Utils.Convert2Comma(Domain);
|
||||
IP = Utils.Convert2Comma(IP);
|
||||
|
@ -88,7 +88,7 @@ namespace ServiceLib.ViewModels
|
|||
return;
|
||||
}
|
||||
//_noticeHandler?.Enqueue(ResUI.OperationSuccess);
|
||||
_updateView?.Invoke(EViewAction.CloseWindow, null);
|
||||
await _updateView?.Invoke(EViewAction.CloseWindow, null);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -34,7 +34,7 @@ namespace ServiceLib.ViewModels
|
|||
|
||||
public ReactiveCommand<Unit, Unit> SaveCmd { get; }
|
||||
|
||||
public RoutingRuleSettingViewModel(RoutingItem routingItem, Func<EViewAction, object?, bool>? updateView)
|
||||
public RoutingRuleSettingViewModel(RoutingItem routingItem, Func<EViewAction, object?, Task<bool>>? updateView)
|
||||
{
|
||||
_config = LazyConfig.Instance.Config;
|
||||
_noticeHandler = Locator.Current.GetService<NoticeHandler>();
|
||||
|
@ -60,15 +60,15 @@ namespace ServiceLib.ViewModels
|
|||
|
||||
RuleAddCmd = ReactiveCommand.Create(() =>
|
||||
{
|
||||
RuleEdit(true);
|
||||
RuleEditAsync(true);
|
||||
});
|
||||
ImportRulesFromFileCmd = ReactiveCommand.Create(() =>
|
||||
ImportRulesFromFileCmd = ReactiveCommand.CreateFromTask(async () =>
|
||||
{
|
||||
_updateView?.Invoke(EViewAction.ImportRulesFromFile, null);
|
||||
await _updateView?.Invoke(EViewAction.ImportRulesFromFile, null);
|
||||
});
|
||||
ImportRulesFromClipboardCmd = ReactiveCommand.Create(() =>
|
||||
{
|
||||
ImportRulesFromClipboard(null);
|
||||
ImportRulesFromClipboardAsync(null);
|
||||
});
|
||||
ImportRulesFromUrlCmd = ReactiveCommand.Create(() =>
|
||||
{
|
||||
|
@ -77,11 +77,11 @@ namespace ServiceLib.ViewModels
|
|||
|
||||
RuleRemoveCmd = ReactiveCommand.Create(() =>
|
||||
{
|
||||
RuleRemove();
|
||||
RuleRemoveAsync();
|
||||
}, canEditRemove);
|
||||
RuleExportSelectedCmd = ReactiveCommand.Create(() =>
|
||||
{
|
||||
RuleExportSelected();
|
||||
RuleExportSelectedAsync();
|
||||
}, canEditRemove);
|
||||
|
||||
MoveTopCmd = ReactiveCommand.Create(() =>
|
||||
|
@ -103,7 +103,7 @@ namespace ServiceLib.ViewModels
|
|||
|
||||
SaveCmd = ReactiveCommand.Create(() =>
|
||||
{
|
||||
SaveRouting();
|
||||
SaveRoutingAsync();
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -129,7 +129,7 @@ namespace ServiceLib.ViewModels
|
|||
}
|
||||
}
|
||||
|
||||
public void RuleEdit(bool blNew)
|
||||
public async Task RuleEditAsync(bool blNew)
|
||||
{
|
||||
RulesItem? item;
|
||||
if (blNew)
|
||||
|
@ -144,7 +144,7 @@ namespace ServiceLib.ViewModels
|
|||
return;
|
||||
}
|
||||
}
|
||||
if (_updateView?.Invoke(EViewAction.RoutingRuleDetailsWindow, item) == true)
|
||||
if (await _updateView?.Invoke(EViewAction.RoutingRuleDetailsWindow, item) == true)
|
||||
{
|
||||
if (blNew)
|
||||
{
|
||||
|
@ -154,14 +154,14 @@ namespace ServiceLib.ViewModels
|
|||
}
|
||||
}
|
||||
|
||||
public void RuleRemove()
|
||||
public async Task RuleRemoveAsync()
|
||||
{
|
||||
if (SelectedSource is null || SelectedSource.outboundTag.IsNullOrEmpty())
|
||||
{
|
||||
_noticeHandler?.Enqueue(ResUI.PleaseSelectRules);
|
||||
return;
|
||||
}
|
||||
if (_updateView?.Invoke(EViewAction.ShowYesNo, null) == false)
|
||||
if (await _updateView?.Invoke(EViewAction.ShowYesNo, null) == false)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
@ -177,7 +177,7 @@ namespace ServiceLib.ViewModels
|
|||
RefreshRulesItems();
|
||||
}
|
||||
|
||||
public void RuleExportSelected()
|
||||
public async Task RuleExportSelectedAsync()
|
||||
{
|
||||
if (SelectedSource is null || SelectedSource.outboundTag.IsNullOrEmpty())
|
||||
{
|
||||
|
@ -197,7 +197,7 @@ namespace ServiceLib.ViewModels
|
|||
}
|
||||
if (lst.Count > 0)
|
||||
{
|
||||
_updateView?.Invoke(EViewAction.SetClipboardData, JsonUtils.Serialize(lst));
|
||||
await _updateView?.Invoke(EViewAction.SetClipboardData, JsonUtils.Serialize(lst));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -221,7 +221,7 @@ namespace ServiceLib.ViewModels
|
|||
}
|
||||
}
|
||||
|
||||
private void SaveRouting()
|
||||
private async Task SaveRoutingAsync()
|
||||
{
|
||||
string remarks = SelectedRouting.remarks;
|
||||
if (Utils.IsNullOrEmpty(remarks))
|
||||
|
@ -240,7 +240,7 @@ namespace ServiceLib.ViewModels
|
|||
if (ConfigHandler.SaveRoutingItem(_config, item) == 0)
|
||||
{
|
||||
_noticeHandler?.Enqueue(ResUI.OperationSuccess);
|
||||
_updateView?.Invoke(EViewAction.CloseWindow, null);
|
||||
await _updateView?.Invoke(EViewAction.CloseWindow, null);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -250,7 +250,7 @@ namespace ServiceLib.ViewModels
|
|||
|
||||
#region Import rules
|
||||
|
||||
public void ImportRulesFromFile(string fileName)
|
||||
public async Task ImportRulesFromFileAsync(string fileName)
|
||||
{
|
||||
if (Utils.IsNullOrEmpty(fileName))
|
||||
{
|
||||
|
@ -262,29 +262,30 @@ namespace ServiceLib.ViewModels
|
|||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (AddBatchRoutingRules(SelectedRouting, result) == 0)
|
||||
var ret = await AddBatchRoutingRulesAsync(SelectedRouting, result);
|
||||
if (ret == 0)
|
||||
{
|
||||
RefreshRulesItems();
|
||||
_noticeHandler?.Enqueue(ResUI.OperationSuccess);
|
||||
}
|
||||
}
|
||||
|
||||
public void ImportRulesFromClipboard(string? clipboardData)
|
||||
public async Task ImportRulesFromClipboardAsync(string? clipboardData)
|
||||
{
|
||||
if (clipboardData == null)
|
||||
{
|
||||
_updateView?.Invoke(EViewAction.ImportRulesFromClipboard, null);
|
||||
await _updateView?.Invoke(EViewAction.ImportRulesFromClipboard, null);
|
||||
return;
|
||||
}
|
||||
if (AddBatchRoutingRules(SelectedRouting, clipboardData) == 0)
|
||||
var ret = await AddBatchRoutingRulesAsync(SelectedRouting, clipboardData);
|
||||
if (ret == 0)
|
||||
{
|
||||
RefreshRulesItems();
|
||||
_noticeHandler?.Enqueue(ResUI.OperationSuccess);
|
||||
}
|
||||
}
|
||||
|
||||
private void ImportRulesFromUrl()
|
||||
private async void ImportRulesFromUrl()
|
||||
{
|
||||
var url = SelectedRouting.url;
|
||||
if (Utils.IsNullOrEmpty(url))
|
||||
|
@ -294,18 +295,19 @@ namespace ServiceLib.ViewModels
|
|||
}
|
||||
|
||||
DownloadHandler downloadHandle = new DownloadHandler();
|
||||
var result = downloadHandle.TryDownloadString(url, true, "").Result;
|
||||
if (AddBatchRoutingRules(SelectedRouting, result) == 0)
|
||||
var result = await downloadHandle.TryDownloadString(url, true, "");
|
||||
var ret = await AddBatchRoutingRulesAsync(SelectedRouting, result);
|
||||
if (ret == 0)
|
||||
{
|
||||
RefreshRulesItems();
|
||||
_noticeHandler?.Enqueue(ResUI.OperationSuccess);
|
||||
}
|
||||
}
|
||||
|
||||
private int AddBatchRoutingRules(RoutingItem routingItem, string? clipboardData)
|
||||
private async Task<int> AddBatchRoutingRulesAsync(RoutingItem routingItem, string? clipboardData)
|
||||
{
|
||||
bool blReplace = false;
|
||||
if (_updateView?.Invoke(EViewAction.AddBatchRoutingRulesYesNo, null) == false)
|
||||
if (await _updateView?.Invoke(EViewAction.AddBatchRoutingRulesYesNo, null) == false)
|
||||
{
|
||||
blReplace = true;
|
||||
}
|
||||
|
|
|
@ -65,7 +65,7 @@ namespace ServiceLib.ViewModels
|
|||
|
||||
#endregion Reactive
|
||||
|
||||
public RoutingSettingViewModel(Func<EViewAction, object?, bool>? updateView)
|
||||
public RoutingSettingViewModel(Func<EViewAction, object?, Task<bool>>? updateView)
|
||||
{
|
||||
_config = LazyConfig.Instance.Config;
|
||||
_noticeHandler = Locator.Current.GetService<NoticeHandler>();
|
||||
|
@ -98,11 +98,11 @@ namespace ServiceLib.ViewModels
|
|||
|
||||
RoutingAdvancedAddCmd = ReactiveCommand.Create(() =>
|
||||
{
|
||||
RoutingAdvancedEdit(true);
|
||||
RoutingAdvancedEditAsync(true);
|
||||
});
|
||||
RoutingAdvancedRemoveCmd = ReactiveCommand.Create(() =>
|
||||
{
|
||||
RoutingAdvancedRemove();
|
||||
RoutingAdvancedRemoveAsync();
|
||||
}, canEditRemove);
|
||||
RoutingAdvancedSetDefaultCmd = ReactiveCommand.Create(() =>
|
||||
{
|
||||
|
@ -115,7 +115,7 @@ namespace ServiceLib.ViewModels
|
|||
|
||||
SaveCmd = ReactiveCommand.Create(() =>
|
||||
{
|
||||
SaveRouting();
|
||||
SaveRoutingAsync();
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -189,7 +189,7 @@ namespace ServiceLib.ViewModels
|
|||
}
|
||||
}
|
||||
|
||||
private void SaveRouting()
|
||||
private async Task SaveRoutingAsync()
|
||||
{
|
||||
_config.routingBasicItem.domainStrategy = domainStrategy;
|
||||
_config.routingBasicItem.enableRoutingAdvanced = enableRoutingAdvanced;
|
||||
|
@ -201,7 +201,7 @@ namespace ServiceLib.ViewModels
|
|||
if (ConfigHandler.SaveConfig(_config) == 0)
|
||||
{
|
||||
_noticeHandler?.Enqueue(ResUI.OperationSuccess);
|
||||
_updateView?.Invoke(EViewAction.CloseWindow, null);
|
||||
await _updateView?.Invoke(EViewAction.CloseWindow, null);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -223,7 +223,7 @@ namespace ServiceLib.ViewModels
|
|||
_noticeHandler?.Enqueue(ResUI.OperationSuccess);
|
||||
}
|
||||
|
||||
public void RoutingAdvancedEdit(bool blNew)
|
||||
public async Task RoutingAdvancedEditAsync(bool blNew)
|
||||
{
|
||||
RoutingItem item;
|
||||
if (blNew)
|
||||
|
@ -238,21 +238,21 @@ namespace ServiceLib.ViewModels
|
|||
return;
|
||||
}
|
||||
}
|
||||
if (_updateView?.Invoke(EViewAction.RoutingRuleSettingWindow, item) == true)
|
||||
if (await _updateView?.Invoke(EViewAction.RoutingRuleSettingWindow, item) == true)
|
||||
{
|
||||
RefreshRoutingItems();
|
||||
IsModified = true;
|
||||
}
|
||||
}
|
||||
|
||||
public void RoutingAdvancedRemove()
|
||||
public async Task RoutingAdvancedRemoveAsync()
|
||||
{
|
||||
if (SelectedSource is null || SelectedSource.remarks.IsNullOrEmpty())
|
||||
{
|
||||
_noticeHandler?.Enqueue(ResUI.PleaseSelectRules);
|
||||
return;
|
||||
}
|
||||
if (_updateView?.Invoke(EViewAction.ShowYesNo, null) == false)
|
||||
if (await _updateView?.Invoke(EViewAction.ShowYesNo, null) == false)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -12,7 +12,7 @@ namespace ServiceLib.ViewModels
|
|||
|
||||
public ReactiveCommand<Unit, Unit> SaveCmd { get; }
|
||||
|
||||
public SubEditViewModel(SubItem subItem, Func<EViewAction, object?, bool>? updateView)
|
||||
public SubEditViewModel(SubItem subItem, Func<EViewAction, object?, Task<bool>>? updateView)
|
||||
{
|
||||
_config = LazyConfig.Instance.Config;
|
||||
_noticeHandler = Locator.Current.GetService<NoticeHandler>();
|
||||
|
@ -29,11 +29,11 @@ namespace ServiceLib.ViewModels
|
|||
|
||||
SaveCmd = ReactiveCommand.Create(() =>
|
||||
{
|
||||
SaveSub();
|
||||
SaveSubAsync();
|
||||
});
|
||||
}
|
||||
|
||||
private void SaveSub()
|
||||
private async Task SaveSubAsync()
|
||||
{
|
||||
string remarks = SelectedSource.remarks;
|
||||
if (Utils.IsNullOrEmpty(remarks))
|
||||
|
@ -45,7 +45,7 @@ namespace ServiceLib.ViewModels
|
|||
if (ConfigHandler.AddSubItem(_config, SelectedSource) == 0)
|
||||
{
|
||||
_noticeHandler?.Enqueue(ResUI.OperationSuccess);
|
||||
_updateView?.Invoke(EViewAction.CloseWindow, null);
|
||||
await _updateView?.Invoke(EViewAction.CloseWindow, null);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -23,7 +23,7 @@ namespace ServiceLib.ViewModels
|
|||
public ReactiveCommand<Unit, Unit> SubShareCmd { get; }
|
||||
public bool IsModified { get; set; }
|
||||
|
||||
public SubSettingViewModel(Func<EViewAction, object?, bool>? updateView)
|
||||
public SubSettingViewModel(Func<EViewAction, object?, Task<bool>>? updateView)
|
||||
{
|
||||
_config = LazyConfig.Instance.Config;
|
||||
_noticeHandler = Locator.Current.GetService<NoticeHandler>();
|
||||
|
@ -39,19 +39,19 @@ namespace ServiceLib.ViewModels
|
|||
|
||||
SubAddCmd = ReactiveCommand.Create(() =>
|
||||
{
|
||||
EditSub(true);
|
||||
EditSubAsync(true);
|
||||
});
|
||||
SubDeleteCmd = ReactiveCommand.Create(() =>
|
||||
{
|
||||
DeleteSub();
|
||||
DeleteSubAsync();
|
||||
}, canEditRemove);
|
||||
SubEditCmd = ReactiveCommand.Create(() =>
|
||||
SubEditCmd = ReactiveCommand.CreateFromTask(async () =>
|
||||
{
|
||||
EditSub(false);
|
||||
await EditSubAsync(false);
|
||||
}, canEditRemove);
|
||||
SubShareCmd = ReactiveCommand.Create(() =>
|
||||
SubShareCmd = ReactiveCommand.CreateFromTask(async () =>
|
||||
{
|
||||
_updateView?.Invoke(EViewAction.ShareSub, SelectedSource?.url);
|
||||
await _updateView?.Invoke(EViewAction.ShareSub, SelectedSource?.url);
|
||||
}, canEditRemove);
|
||||
}
|
||||
|
||||
|
@ -61,7 +61,7 @@ namespace ServiceLib.ViewModels
|
|||
_subItems.AddRange(LazyConfig.Instance.SubItems().OrderBy(t => t.sort));
|
||||
}
|
||||
|
||||
public void EditSub(bool blNew)
|
||||
public async Task EditSubAsync(bool blNew)
|
||||
{
|
||||
SubItem item;
|
||||
if (blNew)
|
||||
|
@ -76,16 +76,16 @@ namespace ServiceLib.ViewModels
|
|||
return;
|
||||
}
|
||||
}
|
||||
if (_updateView?.Invoke(EViewAction.SubEditWindow, item) == true)
|
||||
if (await _updateView?.Invoke(EViewAction.SubEditWindow, item) == true)
|
||||
{
|
||||
RefreshSubItems();
|
||||
IsModified = true;
|
||||
}
|
||||
}
|
||||
|
||||
private void DeleteSub()
|
||||
private async Task DeleteSubAsync()
|
||||
{
|
||||
if (_updateView?.Invoke(EViewAction.ShowYesNo, null) == false)
|
||||
if (await _updateView?.Invoke(EViewAction.ShowYesNo, null) == false)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -37,7 +37,7 @@ namespace v2rayN.Views
|
|||
WindowsUtils.SetDarkBorder(this, LazyConfig.Instance.Config.uiItem.followSystemTheme ? !WindowsUtils.IsLightTheme() : LazyConfig.Instance.Config.uiItem.colorModeDark);
|
||||
}
|
||||
|
||||
private bool UpdateViewHandler(EViewAction action, object? obj)
|
||||
private async Task<bool> UpdateViewHandler(EViewAction action, object? obj)
|
||||
{
|
||||
switch (action)
|
||||
{
|
||||
|
@ -54,7 +54,7 @@ namespace v2rayN.Views
|
|||
break;
|
||||
}
|
||||
|
||||
return true;
|
||||
return await Task.FromResult(true);
|
||||
}
|
||||
|
||||
private void Window_Loaded(object sender, RoutedEventArgs e)
|
||||
|
|
|
@ -220,7 +220,7 @@ namespace v2rayN.Views
|
|||
WindowsUtils.SetDarkBorder(this, LazyConfig.Instance.Config.uiItem.followSystemTheme ? !WindowsUtils.IsLightTheme() : LazyConfig.Instance.Config.uiItem.colorModeDark);
|
||||
}
|
||||
|
||||
private bool UpdateViewHandler(EViewAction action, object? obj)
|
||||
private async Task<bool> UpdateViewHandler(EViewAction action, object? obj)
|
||||
{
|
||||
switch (action)
|
||||
{
|
||||
|
@ -228,7 +228,7 @@ namespace v2rayN.Views
|
|||
this.DialogResult = true;
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
return await Task.FromResult(true);
|
||||
}
|
||||
|
||||
private void Window_Loaded(object sender, RoutedEventArgs e)
|
||||
|
|
|
@ -29,7 +29,7 @@ namespace v2rayN.Views
|
|||
});
|
||||
}
|
||||
|
||||
private bool UpdateViewHandler(EViewAction action, object? obj)
|
||||
private async Task<bool> UpdateViewHandler(EViewAction action, object? obj)
|
||||
{
|
||||
switch (action)
|
||||
{
|
||||
|
@ -42,7 +42,7 @@ namespace v2rayN.Views
|
|||
break;
|
||||
}
|
||||
|
||||
return true;
|
||||
return await Task.FromResult(true);
|
||||
}
|
||||
|
||||
private void btnClose_Click(object sender, System.Windows.RoutedEventArgs e)
|
||||
|
|
|
@ -39,7 +39,7 @@ namespace v2rayN.Views
|
|||
});
|
||||
}
|
||||
|
||||
private bool UpdateViewHandler(EViewAction action, object? obj)
|
||||
private async Task<bool> UpdateViewHandler(EViewAction action, object? obj)
|
||||
{
|
||||
switch (action)
|
||||
{
|
||||
|
@ -60,7 +60,7 @@ namespace v2rayN.Views
|
|||
break;
|
||||
}
|
||||
|
||||
return true;
|
||||
return await Task.FromResult(true);
|
||||
}
|
||||
|
||||
private void ProxiesView_KeyDown(object sender, KeyEventArgs e)
|
||||
|
|
|
@ -53,7 +53,7 @@ namespace v2rayN.Views
|
|||
WindowsUtils.SetDarkBorder(this, LazyConfig.Instance.Config.uiItem.followSystemTheme ? !WindowsUtils.IsLightTheme() : LazyConfig.Instance.Config.uiItem.colorModeDark);
|
||||
}
|
||||
|
||||
private bool UpdateViewHandler(EViewAction action, object? obj)
|
||||
private async Task<bool> UpdateViewHandler(EViewAction action, object? obj)
|
||||
{
|
||||
switch (action)
|
||||
{
|
||||
|
@ -61,7 +61,7 @@ namespace v2rayN.Views
|
|||
this.DialogResult = true;
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
return await Task.FromResult(true);
|
||||
}
|
||||
|
||||
private void linkDnsObjectDoc_Click(object sender, RoutedEventArgs e)
|
||||
|
|
|
@ -204,7 +204,7 @@ namespace v2rayN.Views
|
|||
}), DispatcherPriority.Normal);
|
||||
}
|
||||
|
||||
private bool UpdateViewHandler(EViewAction action, object? obj)
|
||||
private async Task<bool> UpdateViewHandler(EViewAction action, object? obj)
|
||||
{
|
||||
switch (action)
|
||||
{
|
||||
|
@ -291,11 +291,11 @@ namespace v2rayN.Views
|
|||
|
||||
case EViewAction.AddServerViaClipboard:
|
||||
var clipboardData = WindowsUtils.GetClipboardData();
|
||||
ViewModel?.AddServerViaClipboard(clipboardData);
|
||||
ViewModel?.AddServerViaClipboardAsync(clipboardData);
|
||||
break;
|
||||
}
|
||||
|
||||
return true;
|
||||
return await Task.FromResult(true);
|
||||
}
|
||||
|
||||
private void OnHotkeyHandler(EGlobalHotkey e)
|
||||
|
@ -336,14 +336,14 @@ namespace v2rayN.Views
|
|||
|
||||
tbNotify.Dispose();
|
||||
StorageUI();
|
||||
ViewModel?.MyAppExit(false);
|
||||
ViewModel?.MyAppExitAsync(false);
|
||||
}
|
||||
|
||||
private void Current_SessionEnding(object sender, SessionEndingCancelEventArgs e)
|
||||
{
|
||||
Logging.SaveLog("Current_SessionEnding");
|
||||
StorageUI();
|
||||
ViewModel?.MyAppExit(true);
|
||||
ViewModel?.MyAppExitAsync(true);
|
||||
}
|
||||
|
||||
private void MainWindow_PreviewKeyDown(object sender, KeyEventArgs e)
|
||||
|
@ -354,7 +354,7 @@ namespace v2rayN.Views
|
|||
{
|
||||
case Key.V:
|
||||
var clipboardData = WindowsUtils.GetClipboardData();
|
||||
ViewModel?.AddServerViaClipboard(clipboardData);
|
||||
ViewModel?.AddServerViaClipboardAsync(clipboardData);
|
||||
break;
|
||||
|
||||
case Key.S:
|
||||
|
|
|
@ -168,7 +168,7 @@ namespace v2rayN.Views
|
|||
WindowsUtils.SetDarkBorder(this, LazyConfig.Instance.Config.uiItem.followSystemTheme ? !WindowsUtils.IsLightTheme() : LazyConfig.Instance.Config.uiItem.colorModeDark);
|
||||
}
|
||||
|
||||
private bool UpdateViewHandler(EViewAction action, object? obj)
|
||||
private async Task<bool> UpdateViewHandler(EViewAction action, object? obj)
|
||||
{
|
||||
switch (action)
|
||||
{
|
||||
|
@ -177,7 +177,7 @@ namespace v2rayN.Views
|
|||
this.DialogResult = true;
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
return await Task.FromResult(true);
|
||||
}
|
||||
|
||||
private List<string> GetFonts(string path)
|
||||
|
|
|
@ -98,7 +98,7 @@ namespace v2rayN.Views
|
|||
StorageUI();
|
||||
}
|
||||
|
||||
private bool UpdateViewHandler(EViewAction action, object? obj)
|
||||
private async Task<bool> UpdateViewHandler(EViewAction action, object? obj)
|
||||
{
|
||||
switch (action)
|
||||
{
|
||||
|
@ -173,7 +173,7 @@ namespace v2rayN.Views
|
|||
break;
|
||||
}
|
||||
|
||||
return true;
|
||||
return await Task.FromResult(true);
|
||||
}
|
||||
|
||||
public async void ShareServer(string url)
|
||||
|
@ -206,7 +206,7 @@ namespace v2rayN.Views
|
|||
}
|
||||
else
|
||||
{
|
||||
ViewModel?.EditServer(EConfigType.Custom);
|
||||
ViewModel?.EditServerAsync(EConfigType.Custom);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -238,15 +238,15 @@ namespace v2rayN.Views
|
|||
break;
|
||||
|
||||
case Key.C:
|
||||
ViewModel?.Export2ShareUrl(false);
|
||||
ViewModel?.Export2ShareUrlAsync(false);
|
||||
break;
|
||||
|
||||
case Key.D:
|
||||
ViewModel?.EditServer(EConfigType.Custom);
|
||||
ViewModel?.EditServerAsync(EConfigType.Custom);
|
||||
break;
|
||||
|
||||
case Key.F:
|
||||
ViewModel?.ShareServer();
|
||||
ViewModel?.ShareServerAsync();
|
||||
break;
|
||||
|
||||
case Key.O:
|
||||
|
@ -274,7 +274,7 @@ namespace v2rayN.Views
|
|||
}
|
||||
else if (e.Key == Key.Delete)
|
||||
{
|
||||
ViewModel?.RemoveServer();
|
||||
ViewModel?.RemoveServerAsync();
|
||||
}
|
||||
else if (e.Key == Key.T)
|
||||
{
|
||||
|
|
|
@ -60,7 +60,7 @@ namespace v2rayN.Views
|
|||
WindowsUtils.SetDarkBorder(this, LazyConfig.Instance.Config.uiItem.followSystemTheme ? !WindowsUtils.IsLightTheme() : LazyConfig.Instance.Config.uiItem.colorModeDark);
|
||||
}
|
||||
|
||||
private bool UpdateViewHandler(EViewAction action, object? obj)
|
||||
private async Task<bool> UpdateViewHandler(EViewAction action, object? obj)
|
||||
{
|
||||
switch (action)
|
||||
{
|
||||
|
@ -68,7 +68,7 @@ namespace v2rayN.Views
|
|||
this.DialogResult = true;
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
return await Task.FromResult(true);
|
||||
}
|
||||
|
||||
private void Window_Loaded(object sender, RoutedEventArgs e)
|
||||
|
|
|
@ -60,7 +60,7 @@ namespace v2rayN.Views
|
|||
WindowsUtils.SetDarkBorder(this, LazyConfig.Instance.Config.uiItem.followSystemTheme ? !WindowsUtils.IsLightTheme() : LazyConfig.Instance.Config.uiItem.colorModeDark);
|
||||
}
|
||||
|
||||
private bool UpdateViewHandler(EViewAction action, object? obj)
|
||||
private async Task<bool> UpdateViewHandler(EViewAction action, object? obj)
|
||||
{
|
||||
switch (action)
|
||||
{
|
||||
|
@ -95,7 +95,7 @@ namespace v2rayN.Views
|
|||
{
|
||||
return false;
|
||||
}
|
||||
ViewModel?.ImportRulesFromFile(fileName);
|
||||
ViewModel?.ImportRulesFromFileAsync(fileName);
|
||||
break;
|
||||
|
||||
case EViewAction.SetClipboardData:
|
||||
|
@ -105,11 +105,11 @@ namespace v2rayN.Views
|
|||
|
||||
case EViewAction.ImportRulesFromClipboard:
|
||||
var clipboardData = WindowsUtils.GetClipboardData();
|
||||
ViewModel?.ImportRulesFromClipboard(clipboardData);
|
||||
ViewModel?.ImportRulesFromClipboardAsync(clipboardData);
|
||||
break;
|
||||
}
|
||||
|
||||
return true;
|
||||
return await Task.FromResult(true);
|
||||
}
|
||||
|
||||
private void Window_Loaded(object sender, RoutedEventArgs e)
|
||||
|
@ -127,7 +127,7 @@ namespace v2rayN.Views
|
|||
}
|
||||
else if (e.Key == Key.C)
|
||||
{
|
||||
ViewModel?.RuleExportSelected();
|
||||
ViewModel?.RuleExportSelectedAsync();
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -150,7 +150,7 @@ namespace v2rayN.Views
|
|||
}
|
||||
else if (e.Key == Key.Delete)
|
||||
{
|
||||
ViewModel?.RuleRemove();
|
||||
ViewModel?.RuleRemoveAsync();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -162,7 +162,7 @@ namespace v2rayN.Views
|
|||
|
||||
private void LstRules_MouseDoubleClick(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
ViewModel?.RuleEdit(false);
|
||||
ViewModel?.RuleEditAsync(false);
|
||||
}
|
||||
|
||||
private void menuRuleSelectAll_Click(object sender, System.Windows.RoutedEventArgs e)
|
||||
|
|
|
@ -67,7 +67,7 @@ namespace v2rayN.Views
|
|||
WindowsUtils.SetDarkBorder(this, LazyConfig.Instance.Config.uiItem.followSystemTheme ? !WindowsUtils.IsLightTheme() : LazyConfig.Instance.Config.uiItem.colorModeDark);
|
||||
}
|
||||
|
||||
private bool UpdateViewHandler(EViewAction action, object? obj)
|
||||
private async Task<bool> UpdateViewHandler(EViewAction action, object? obj)
|
||||
{
|
||||
switch (action)
|
||||
{
|
||||
|
@ -87,7 +87,7 @@ namespace v2rayN.Views
|
|||
if (obj is null) return false;
|
||||
return (new RoutingRuleSettingWindow((RoutingItem)obj)).ShowDialog() ?? false;
|
||||
}
|
||||
return true;
|
||||
return await Task.FromResult(true);
|
||||
}
|
||||
|
||||
private void RoutingSettingWindow_Closing(object? sender, System.ComponentModel.CancelEventArgs e)
|
||||
|
@ -118,7 +118,7 @@ namespace v2rayN.Views
|
|||
}
|
||||
else if (e.Key == Key.Delete)
|
||||
{
|
||||
ViewModel?.RoutingAdvancedRemove();
|
||||
ViewModel?.RoutingAdvancedRemoveAsync();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -134,7 +134,7 @@ namespace v2rayN.Views
|
|||
|
||||
private void LstRoutings_MouseDoubleClick(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
ViewModel?.RoutingAdvancedEdit(false);
|
||||
ViewModel?.RoutingAdvancedEditAsync(false);
|
||||
}
|
||||
|
||||
private void linkdomainStrategy_Click(object sender, System.Windows.RoutedEventArgs e)
|
||||
|
|
|
@ -39,7 +39,7 @@ namespace v2rayN.Views
|
|||
WindowsUtils.SetDarkBorder(this, LazyConfig.Instance.Config.uiItem.followSystemTheme ? !WindowsUtils.IsLightTheme() : LazyConfig.Instance.Config.uiItem.colorModeDark);
|
||||
}
|
||||
|
||||
private bool UpdateViewHandler(EViewAction action, object? obj)
|
||||
private async Task<bool> UpdateViewHandler(EViewAction action, object? obj)
|
||||
{
|
||||
switch (action)
|
||||
{
|
||||
|
@ -47,7 +47,7 @@ namespace v2rayN.Views
|
|||
this.DialogResult = true;
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
return await Task.FromResult(true);
|
||||
}
|
||||
|
||||
private void Window_Loaded(object sender, RoutedEventArgs e)
|
||||
|
|
|
@ -33,7 +33,7 @@ namespace v2rayN.Views
|
|||
WindowsUtils.SetDarkBorder(this, LazyConfig.Instance.Config.uiItem.followSystemTheme ? !WindowsUtils.IsLightTheme() : LazyConfig.Instance.Config.uiItem.colorModeDark);
|
||||
}
|
||||
|
||||
private bool UpdateViewHandler(EViewAction action, object? obj)
|
||||
private async Task<bool> UpdateViewHandler(EViewAction action, object? obj)
|
||||
{
|
||||
switch (action)
|
||||
{
|
||||
|
@ -57,7 +57,7 @@ namespace v2rayN.Views
|
|||
ShareSub((string)obj);
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
return await Task.FromResult(true);
|
||||
}
|
||||
|
||||
private async void ShareSub(string url)
|
||||
|
@ -86,7 +86,7 @@ namespace v2rayN.Views
|
|||
|
||||
private void LstSubscription_MouseDoubleClick(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
ViewModel?.EditSub(false);
|
||||
ViewModel?.EditSubAsync(false);
|
||||
}
|
||||
|
||||
private void LstSubscription_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e)
|
||||
|
|
Loading…
Reference in New Issue