Skip to content

Commit 4c4705a

Browse files
committed
enhance: only remember active tab index of commit details panel in HISTORY page
Signed-off-by: leo <[email protected]>
1 parent 28b8325 commit 4c4705a

File tree

4 files changed

+13
-11
lines changed

4 files changed

+13
-11
lines changed

src/ViewModels/CommitDetail.cs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,13 @@ public partial class CommitDetail : ObservableObject, IDisposable
1717
{
1818
public int ActivePageIndex
1919
{
20-
get => _repo.CommitDetailActivePageIndex;
20+
get => _rememberActivePageIndex ? _repo.CommitDetailActivePageIndex : _activePageIndex;
2121
set
2222
{
23-
if (_repo.CommitDetailActivePageIndex != value)
24-
{
23+
if (_rememberActivePageIndex)
2524
_repo.CommitDetailActivePageIndex = value;
26-
OnPropertyChanged();
27-
}
25+
else
26+
_activePageIndex = value;
2827
}
2928
}
3029

@@ -139,9 +138,10 @@ public bool CanOpenRevisionFileWithDefaultEditor
139138
private set => SetProperty(ref _canOpenRevisionFileWithDefaultEditor, value);
140139
}
141140

142-
public CommitDetail(Repository repo)
141+
public CommitDetail(Repository repo, bool rememberActivePageIndex)
143142
{
144143
_repo = repo;
144+
_rememberActivePageIndex = rememberActivePageIndex;
145145
WebLinks = Models.CommitLink.Get(repo.Remotes);
146146
}
147147

@@ -1026,6 +1026,8 @@ private Task ResetToParentRevision(Models.Change change)
10261026
private static partial Regex REG_SHA_FORMAT();
10271027

10281028
private Repository _repo = null;
1029+
private bool _rememberActivePageIndex = true;
1030+
private int _activePageIndex = 0;
10291031
private Models.Commit _commit = null;
10301032
private Models.CommitFullMessage _fullMessage = null;
10311033
private Models.CommitSignInfo _signInfo = null;

src/ViewModels/DirHistories.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,11 @@ public DirHistories(Repository repo, string dir, string revision = null)
4848
Title = dir;
4949

5050
_repo = repo;
51-
_detail = new CommitDetail(repo);
51+
_detail = new CommitDetail(repo, false);
5252

5353
Task.Run(() =>
5454
{
55-
var commits = new Commands.QueryCommits(_repo.FullPath, $"--date-order -n 10000 {revision??string.Empty} -- \"{dir}\"", false).Result();
55+
var commits = new Commands.QueryCommits(_repo.FullPath, $"--date-order -n 10000 {revision ?? string.Empty} -- \"{dir}\"", false).Result();
5656
Dispatcher.UIThread.Invoke(() =>
5757
{
5858
Commits = commits;

src/ViewModels/Histories.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ public void NavigateTo(string commitSHA)
156156
}
157157
else
158158
{
159-
var commitDetail = new CommitDetail(_repo);
159+
var commitDetail = new CommitDetail(_repo, true);
160160
commitDetail.Commit = commit;
161161
DetailContext = commitDetail;
162162
}
@@ -189,7 +189,7 @@ public void Select(IList commits)
189189
}
190190
else
191191
{
192-
var commitDetail = new CommitDetail(_repo);
192+
var commitDetail = new CommitDetail(_repo, true);
193193
commitDetail.Commit = commit;
194194
DetailContext = commitDetail;
195195
}

src/ViewModels/InteractiveRebase.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ public InteractiveRebase(Repository repo, Models.Branch current, Models.Commit o
129129
Current = current;
130130
On = on;
131131
IsLoading = true;
132-
DetailContext = new CommitDetail(repo);
132+
DetailContext = new CommitDetail(repo, false);
133133

134134
Task.Run(() =>
135135
{

0 commit comments

Comments
 (0)