Refactor_updateView to add task

This commit is contained in:
2dust
2024-08-22 19:51:10 +08:00
parent b936c194e4
commit b57cdd31bd
27 changed files with 218 additions and 216 deletions
@@ -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);
}
}
}