mirror of
https://github.com/bolucat/Archive.git
synced 2026-04-23 00:17:16 +08:00
Update On Mon Oct 21 20:36:26 CEST 2024
This commit is contained in:
@@ -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,12 +47,21 @@ namespace ServiceLib.ViewModels
|
||||
{
|
||||
await _updateView?.Invoke(EViewAction.ShareSub, SelectedSource?.url);
|
||||
}, canEditRemove);
|
||||
|
||||
Init();
|
||||
}
|
||||
|
||||
public void RefreshSubItems()
|
||||
private async Task Init()
|
||||
{
|
||||
SelectedSource = new();
|
||||
|
||||
await RefreshSubItems();
|
||||
}
|
||||
|
||||
public async Task RefreshSubItems()
|
||||
{
|
||||
_subItems.Clear();
|
||||
_subItems.AddRange(AppHandler.Instance.SubItems().OrderBy(t => t.sort));
|
||||
_subItems.AddRange(await AppHandler.Instance.SubItems());
|
||||
}
|
||||
|
||||
public async Task EditSubAsync(bool blNew)
|
||||
@@ -69,7 +73,7 @@ namespace ServiceLib.ViewModels
|
||||
}
|
||||
else
|
||||
{
|
||||
item = AppHandler.Instance.GetSubItem(SelectedSource?.id);
|
||||
item = await AppHandler.Instance.GetSubItem(SelectedSource?.id);
|
||||
if (item is null)
|
||||
{
|
||||
return;
|
||||
@@ -77,7 +81,7 @@ namespace ServiceLib.ViewModels
|
||||
}
|
||||
if (await _updateView?.Invoke(EViewAction.SubEditWindow, item) == true)
|
||||
{
|
||||
RefreshSubItems();
|
||||
await RefreshSubItems();
|
||||
IsModified = true;
|
||||
}
|
||||
}
|
||||
@@ -91,9 +95,9 @@ namespace ServiceLib.ViewModels
|
||||
|
||||
foreach (var it in SelectedSources ?? [SelectedSource])
|
||||
{
|
||||
ConfigHandler.DeleteSubItem(_config, it.id);
|
||||
await ConfigHandler.DeleteSubItem(_config, it.id);
|
||||
}
|
||||
RefreshSubItems();
|
||||
await RefreshSubItems();
|
||||
NoticeHandler.Instance.Enqueue(ResUI.OperationSuccess);
|
||||
IsModified = true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user