From e884f27f67fb79a421421941ce3228882c8b315f Mon Sep 17 00:00:00 2001 From: leo Date: Tue, 4 Mar 2025 18:02:29 +0800 Subject: [PATCH] code_style: re-order `CommitDetail` properties Signed-off-by: leo --- src/ViewModels/CommitDetail.cs | 105 +++++++++++++++++---------------- 1 file changed, 54 insertions(+), 51 deletions(-) diff --git a/src/ViewModels/CommitDetail.cs b/src/ViewModels/CommitDetail.cs index 26fa37c1..21931181 100644 --- a/src/ViewModels/CommitDetail.cs +++ b/src/ViewModels/CommitDetail.cs @@ -16,12 +16,6 @@ namespace SourceGit.ViewModels { public partial class CommitDetail : ObservableObject { - public DiffContext DiffContext - { - get => _diffContext; - private set => SetProperty(ref _diffContext, value); - } - public int ActivePageIndex { get => _repo.CommitDetailActivePageIndex; @@ -57,6 +51,18 @@ namespace SourceGit.ViewModels private set => SetProperty(ref _signInfo, value); } + public List WebLinks + { + get; + private set; + } = []; + + public List Children + { + get => _children; + private set => SetProperty(ref _children, value); + } + public List Changes { get => _changes; @@ -84,10 +90,10 @@ namespace SourceGit.ViewModels } } - public List Children + public DiffContext DiffContext { - get => _children; - private set => SetProperty(ref _children, value); + get => _diffContext; + private set => SetProperty(ref _diffContext, value); } public string SearchChangeFilter @@ -108,53 +114,13 @@ namespace SourceGit.ViewModels set => SetProperty(ref _viewRevisionFileContent, value); } - public List WebLinks - { - get; - private set; - } = []; - public string RevisionFileSearchFilter { get => _revisionFileSearchFilter; set { if (SetProperty(ref _revisionFileSearchFilter, value)) - { - if (!string.IsNullOrEmpty(value)) - { - if (_revisionFiles == null) - { - var sha = Commit.SHA; - - Task.Run(() => - { - var files = new Commands.QueryRevisionFileNames(_repo.FullPath, sha).Result(); - var filesList = new List(); - filesList.AddRange(files); - - Dispatcher.UIThread.Invoke(() => - { - if (sha == Commit.SHA) - { - _revisionFiles = filesList; - if (!string.IsNullOrEmpty(_revisionFileSearchFilter)) - UpdateRevisionFileSearchSuggestion(); - } - }); - }); - } - else - { - UpdateRevisionFileSearchSuggestion(); - } - } - else - { - RevisionFileSearchSuggestion = null; - GC.Collect(); - } - } + RefreshRevisionSearchSuggestion(); } } @@ -832,7 +798,44 @@ namespace SourceGit.ViewModels menu.Items.Add(new MenuItem() { Header = "-" }); } - private void UpdateRevisionFileSearchSuggestion() + private void RefreshRevisionSearchSuggestion() + { + if (!string.IsNullOrEmpty(_revisionFileSearchFilter)) + { + if (_revisionFiles == null) + { + var sha = Commit.SHA; + + Task.Run(() => + { + var files = new Commands.QueryRevisionFileNames(_repo.FullPath, sha).Result(); + var filesList = new List(); + filesList.AddRange(files); + + Dispatcher.UIThread.Invoke(() => + { + if (sha == Commit.SHA) + { + _revisionFiles = filesList; + if (!string.IsNullOrEmpty(_revisionFileSearchFilter)) + CalcRevisionFileSearchSuggestion(); + } + }); + }); + } + else + { + CalcRevisionFileSearchSuggestion(); + } + } + else + { + RevisionFileSearchSuggestion = null; + GC.Collect(); + } + } + + private void CalcRevisionFileSearchSuggestion() { var suggestion = new List(); foreach (var file in _revisionFiles)