Compare commits

...

1 Commits

Author SHA1 Message Date
qhy040404
92c38ae77a fix #1608 2024-05-18 15:59:59 +08:00
2 changed files with 18 additions and 4 deletions

View File

@@ -1556,6 +1556,12 @@
<data name="ViewModelCultivationProjectInvalidName" xml:space="preserve">
<value>不能添加名称无效的计划</value>
</data>
<data name="ViewModelCultivationRemoveProjectContent" xml:space="preserve">
<value>此操作不可逆,此计划和其内的背包物品会丢失</value>
</data>
<data name="ViewModelCultivationRemoveProjectTitle" xml:space="preserve">
<value>确认要删除当前计划吗?</value>
</data>
<data name="ViewModelDailyNoteConfigWebhookUrlComplete" xml:space="preserve">
<value>实时便笺 Webhook Url 配置成功</value>
</data>

View File

@@ -1,6 +1,7 @@
// Copyright (c) DGP Studio. All rights reserved.
// Licensed under the MIT license.
using Microsoft.UI.Xaml.Controls;
using Snap.Hutao.Factory.ContentDialog;
using Snap.Hutao.Model.Entity;
using Snap.Hutao.Service.Cultivation;
@@ -110,10 +111,17 @@ internal sealed partial class CultivationViewModel : Abstraction.ViewModel
return;
}
await cultivationService.RemoveProjectAsync(project).ConfigureAwait(false);
await taskContext.SwitchToMainThreadAsync();
ArgumentNullException.ThrowIfNull(Projects);
SelectedProject = Projects.FirstOrDefault();
ContentDialogResult result = await contentDialogFactory
.CreateForConfirmCancelAsync(SH.ViewModelCultivationRemoveProjectTitle, SH.ViewModelCultivationRemoveProjectContent)
.ConfigureAwait(false);
if (result is ContentDialogResult.Primary)
{
await cultivationService.RemoveProjectAsync(project).ConfigureAwait(false);
await taskContext.SwitchToMainThreadAsync();
ArgumentNullException.ThrowIfNull(Projects);
SelectedProject = Projects.FirstOrDefault();
}
}
private async ValueTask UpdateEntryCollectionAsync(CultivateProject? project)