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
@@ -25,13 +25,8 @@ namespace ServiceLib.ViewModels
public SubSettingViewModel(Func<EViewAction, object?, Task<bool>>? updateView)
{
_config = AppHandler.Instance.Config;
_updateView = updateView;
SelectedSource = new();
RefreshSubItems();
var canEditRemove = this.WhenAnyValue(
x => x.SelectedSource,
selectedSource => selectedSource != null && !selectedSource.id.IsNullOrEmpty());
@@ -52,6 +47,15 @@ namespace ServiceLib.ViewModels
{
await _updateView?.Invoke(EViewAction.ShareSub, SelectedSource?.url);
}, canEditRemove);
Init();
}
private async Task Init()
{
SelectedSource = new();
await RefreshSubItems();
}
public async Task RefreshSubItems()