Code optimization, function asynchrony

This commit is contained in:
2dust
2024-10-21 13:46:13 +08:00
parent a866017b4c
commit 3dd54312e7
22 changed files with 258 additions and 266 deletions
@@ -14,27 +14,19 @@ namespace ServiceLib.ViewModels
public SubEditViewModel(SubItem subItem, Func<EViewAction, object?, Task<bool>>? updateView)
{
_config = AppHandler.Instance.Config;
_updateView = updateView;
if (subItem.id.IsNullOrEmpty())
{
SelectedSource = subItem;
}
else
{
SelectedSource = JsonUtils.DeepCopy(subItem);
}
SaveCmd = ReactiveCommand.CreateFromTask(async () =>
{
await SaveSubAsync();
});
SelectedSource = subItem.id.IsNullOrEmpty() ? subItem : JsonUtils.DeepCopy(subItem);
}
private async Task SaveSubAsync()
{
string remarks = SelectedSource.remarks;
var remarks = SelectedSource.remarks;
if (Utils.IsNullOrEmpty(remarks))
{
NoticeHandler.Instance.Enqueue(ResUI.PleaseFillRemarks);