Skip to content

Commit 5425fa6

Browse files
committed
refactor: use another way to open tooltip of SHA after getting commit info (#810)
1 parent e4cfca0 commit 5425fa6

File tree

1 file changed

+16
-7
lines changed

1 file changed

+16
-7
lines changed

src/Views/CommitBaseInfo.axaml.cs

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
using Avalonia.Controls;
66
using Avalonia.Input;
77
using Avalonia.Interactivity;
8+
using Avalonia.Threading;
89

910
namespace SourceGit.Views
1011
{
@@ -124,22 +125,30 @@ private void OnOpenContainsIn(object sender, RoutedEventArgs e)
124125
e.Handled = true;
125126
}
126127

127-
private async void OnSHAPointerEntered(object sender, PointerEventArgs e)
128+
private void OnSHAPointerEntered(object sender, PointerEventArgs e)
128129
{
129130
if (DataContext is ViewModels.CommitDetail detail && sender is Control { DataContext: string sha } ctl)
130131
{
131132
var tooltip = ToolTip.GetTip(ctl);
132133
if (tooltip is Models.Commit commit && commit.SHA == sha)
133134
return;
134135

135-
var c = await Task.Run(() => detail.GetParent(sha));
136-
if (c != null && ctl.IsVisible && ctl.DataContext is string newSHA && newSHA == sha)
136+
Task.Run(() =>
137137
{
138-
ToolTip.SetTip(ctl, c);
138+
var c = detail.GetParent(sha);
139+
if (c == null) return;
139140

140-
if (ctl.IsPointerOver)
141-
ToolTip.SetIsOpen(ctl, true);
142-
}
141+
Dispatcher.UIThread.Invoke(() =>
142+
{
143+
if (ctl.IsEffectivelyVisible && ctl.DataContext is string newSHA && newSHA == sha)
144+
{
145+
ToolTip.SetTip(ctl, c);
146+
147+
if (ctl.IsPointerOver)
148+
ToolTip.SetIsOpen(ctl, true);
149+
}
150+
});
151+
});
143152
}
144153

145154
e.Handled = true;

0 commit comments

Comments
 (0)