Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 13 additions & 7 deletions src/ViewModels/Histories.cs
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,11 @@ public void Select(IList commits)
{
_repo.SearchResultSelectedCommit = null;
DetailContext = null;

return;
}
else if (commits.Count == 1)

if (commits.Count == 1)
{
var commit = (commits[0] as Models.Commit)!;
if (_repo.SearchResultSelectedCommit == null || _repo.SearchResultSelectedCommit.SHA != commit.SHA)
Expand All @@ -170,20 +173,23 @@ public void Select(IList commits)
commitDetail.Commit = commit;
DetailContext = commitDetail;
}

return;
}
else if (commits.Count == 2)

if (commits.Count == 2)
{
_repo.SearchResultSelectedCommit = null;

var end = commits[0] as Models.Commit;
var start = commits[1] as Models.Commit;
DetailContext = new RevisionCompare(_repo.FullPath, start, end);

return;
}
else
{
_repo.SearchResultSelectedCommit = null;
DetailContext = commits.Count;
}

_repo.SearchResultSelectedCommit = null;
DetailContext = commits.Count;
}

public void DoubleTapped(Models.Commit commit)
Expand Down
12 changes: 11 additions & 1 deletion src/Views/Histories.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;
using System.Reflection;

using Avalonia;
using Avalonia.Collections;
Expand Down Expand Up @@ -730,7 +731,16 @@ private void OnCommitListContextRequested(object sender, ContextRequestedEventAr

private void OnCommitListDoubleTapped(object sender, TappedEventArgs e)
{
if (DataContext is ViewModels.Histories histories && sender is ListBox { SelectedItems: { Count: 1 } selected })
// Retrieve the PropertyInfo for the "Name" property
var nameProperty = e.Source.GetType().GetProperty("Name");

// Get the value of the "Name" property, or null if it doesn't exist
string nameValue = nameProperty?.GetValue(e.Source) as string;

// Check if has clicked the Background of the ListBox
bool isInvalidUiPressed = nameValue == "PART_ContentPresenter";

if (DataContext is ViewModels.Histories histories && !isInvalidUiPressed && sender is ListBox { SelectedItems: { Count: 1 } selected })
{
histories.DoubleTapped(selected[0] as Models.Commit);
}
Expand Down
Loading