diff --git a/src/SourceGit.csproj b/src/SourceGit.csproj index ee376f3a..468d55e9 100644 --- a/src/SourceGit.csproj +++ b/src/SourceGit.csproj @@ -37,11 +37,11 @@ - - - - - + + + + + diff --git a/src/ViewModels/Histories.cs b/src/ViewModels/Histories.cs index 4a0a05a0..85be27af 100644 --- a/src/ViewModels/Histories.cs +++ b/src/ViewModels/Histories.cs @@ -243,7 +243,7 @@ namespace SourceGit.ViewModels reword.Icon = App.CreateMenuIcon("Icons.Edit"); reword.Click += (_, e) => { - if (_repo.WorkingCopyChangesCount > 0) + if (_repo.LocalChangesCount > 0) { App.RaiseException(_repo.FullPath, "You have local changes. Please run stash or discard first."); return; @@ -261,7 +261,7 @@ namespace SourceGit.ViewModels squash.IsEnabled = commit.Parents.Count == 1; squash.Click += (_, e) => { - if (_repo.WorkingCopyChangesCount > 0) + if (_repo.LocalChangesCount > 0) { App.RaiseException(_repo.FullPath, "You have local changes. Please run stash or discard first."); return; @@ -322,7 +322,7 @@ namespace SourceGit.ViewModels interactiveRebase.IsVisible = current.Head != commit.SHA; interactiveRebase.Click += (_, e) => { - if (_repo.WorkingCopyChangesCount > 0) + if (_repo.LocalChangesCount > 0) { App.RaiseException(_repo.FullPath, "You have local changes. Please run stash or discard first."); return; @@ -379,7 +379,7 @@ namespace SourceGit.ViewModels }; menu.Items.Add(compareWithHead); - if (_repo.WorkingCopyChangesCount > 0) + if (_repo.LocalChangesCount > 0) { var compareWithWorktree = new MenuItem(); compareWithWorktree.Header = App.Text("CommitCM.CompareWithWorktree"); diff --git a/src/ViewModels/Repository.cs b/src/ViewModels/Repository.cs index 6cbe9576..0ba1c51d 100644 --- a/src/ViewModels/Repository.cs +++ b/src/ViewModels/Repository.cs @@ -142,14 +142,16 @@ namespace SourceGit.ViewModels private set => SetProperty(ref _submodules, value); } - public int WorkingCopyChangesCount + public int LocalChangesCount { - get => _workingCopy == null ? 0 : _workingCopy.Count; + get => _localChangesCount; + private set => SetProperty(ref _localChangesCount, value); } public int StashesCount { - get => _stashesPage == null ? 0 : _stashesPage.Stashes.Count; + get => _stashesCount; + private set => SetProperty(ref _stashesCount, value); } public bool IncludeUntracked @@ -350,6 +352,9 @@ namespace SourceGit.ViewModels _stashesPage = null; _inProgressContext = null; + _localChangesCount = 0; + _stashesCount = 0; + _remotes.Clear(); _branches.Clear(); _localBranchTrees.Clear(); @@ -834,7 +839,7 @@ namespace SourceGit.ViewModels { InProgressContext = inProgress; HasUnsolvedConflicts = hasUnsolvedConflict; - OnPropertyChanged(nameof(WorkingCopyChangesCount)); + LocalChangesCount = changes.Count; }); } @@ -845,7 +850,8 @@ namespace SourceGit.ViewModels { if (_stashesPage != null) _stashesPage.Stashes = stashes; - OnPropertyChanged(nameof(StashesCount)); + + StashesCount = stashes.Count; }); } @@ -878,7 +884,7 @@ namespace SourceGit.ViewModels if (branch.IsLocal) { - if (WorkingCopyChangesCount > 0) + if (_localChangesCount > 0) PopupHost.ShowPopup(new Checkout(this, branch.Name)); else PopupHost.ShowAndStartPopup(new Checkout(this, branch.Name)); @@ -1215,7 +1221,7 @@ namespace SourceGit.ViewModels var discard = new MenuItem(); discard.Header = App.Text("BranchCM.DiscardAll"); discard.Icon = App.CreateMenuIcon("Icons.Undo"); - discard.IsEnabled = _workingCopy.Count > 0; + discard.IsEnabled = _localChangesCount > 0; discard.Click += (_, e) => { if (PopupHost.CanCreatePopup()) @@ -1319,7 +1325,7 @@ namespace SourceGit.ViewModels menu.Items.Add(merge); menu.Items.Add(rebase); - if (WorkingCopyChangesCount > 0) + if (_localChangesCount > 0) { var compareWithWorktree = new MenuItem(); compareWithWorktree.Header = App.Text("BranchCM.CompareWithWorktree"); @@ -1342,7 +1348,7 @@ namespace SourceGit.ViewModels var compareWithBranch = CreateMenuItemToCompareBranches(branch); if (compareWithBranch != null) { - if (WorkingCopyChangesCount == 0) + if (_localChangesCount == 0) menu.Items.Add(new MenuItem() { Header = "-" }); menu.Items.Add(compareWithBranch); @@ -1619,7 +1625,7 @@ namespace SourceGit.ViewModels } var hasCompare = false; - if (WorkingCopyChangesCount > 0) + if (_localChangesCount > 0) { var compareWithWorktree = new MenuItem(); compareWithWorktree.Header = App.Text("BranchCM.CompareWithWorktree"); @@ -1981,6 +1987,9 @@ namespace SourceGit.ViewModels private int _selectedViewIndex = 0; private object _selectedView = null; + private int _localChangesCount = 0; + private int _stashesCount = 0; + private bool _isSearching = false; private bool _isSearchLoadingVisible = false; private bool _isSearchCommitSuggestionOpen = false; diff --git a/src/ViewModels/WorkingCopy.cs b/src/ViewModels/WorkingCopy.cs index 9658eb48..36ab33ca 100644 --- a/src/ViewModels/WorkingCopy.cs +++ b/src/ViewModels/WorkingCopy.cs @@ -177,8 +177,6 @@ namespace SourceGit.ViewModels } } - public int Count => _count; - public object DetailContext { get => _detailContext; diff --git a/src/Views/Repository.axaml b/src/Views/Repository.axaml index 9c111eb7..65747a57 100644 --- a/src/Views/Repository.axaml +++ b/src/Views/Repository.axaml @@ -97,8 +97,8 @@ CornerRadius="9" VerticalAlignment="Center" Background="{DynamicResource Brush.Badge}" - IsVisible="{Binding WorkingCopyChangesCount, Converter={x:Static c:IntConverters.IsGreaterThanZero}}"> - + IsVisible="{Binding LocalChangesCount, Converter={x:Static c:IntConverters.IsGreaterThanZero}}"> +