From 0077751f7542238083ab3d638754689fe7ffee62 Mon Sep 17 00:00:00 2001 From: 2dust <31833384+2dust@users.noreply.github.com> Date: Wed, 26 Nov 2025 20:11:14 +0800 Subject: [PATCH] Add subscription delete functionality to ProfilesView --- .../ViewModels/ProfilesViewModel.cs | 23 +++++++++++++++++++ .../v2rayN.Desktop/Views/ProfilesView.axaml | 8 +++++++ .../Views/ProfilesView.axaml.cs | 3 +++ 3 files changed, 34 insertions(+) diff --git a/v2rayN/ServiceLib/ViewModels/ProfilesViewModel.cs b/v2rayN/ServiceLib/ViewModels/ProfilesViewModel.cs index 80461288..0bbdb208 100644 --- a/v2rayN/ServiceLib/ViewModels/ProfilesViewModel.cs +++ b/v2rayN/ServiceLib/ViewModels/ProfilesViewModel.cs @@ -77,6 +77,7 @@ public class ProfilesViewModel : MyReactiveObject public ReactiveCommand AddSubCmd { get; } public ReactiveCommand EditSubCmd { get; } + public ReactiveCommand DeleteSubCmd { get; } #endregion Menu @@ -235,6 +236,10 @@ public class ProfilesViewModel : MyReactiveObject { await EditSubAsync(false); }); + DeleteSubCmd = ReactiveCommand.CreateFromTask(async () => + { + await DeleteSubAsync(); + }); #endregion WhenAnyValue && ReactiveCommand @@ -884,5 +889,23 @@ public class ProfilesViewModel : MyReactiveObject } } + private async Task DeleteSubAsync() + { + var item = await AppManager.Instance.GetSubItem(_config.SubIndexId); + if (item is null) + { + return; + } + + if (await _updateView?.Invoke(EViewAction.ShowYesNo, null) == false) + { + return; + } + await ConfigHandler.DeleteSubItem(_config, item.Id); + + await RefreshSubscriptions(); + await SubSelectedChangedAsync(true); + } + #endregion Subscription } diff --git a/v2rayN/v2rayN.Desktop/Views/ProfilesView.axaml b/v2rayN/v2rayN.Desktop/Views/ProfilesView.axaml index c84a7151..dc5f2e86 100644 --- a/v2rayN/v2rayN.Desktop/Views/ProfilesView.axaml +++ b/v2rayN/v2rayN.Desktop/Views/ProfilesView.axaml @@ -28,6 +28,14 @@ + + + + + + + +