diff --git a/src/ViewModels/Blame.cs b/src/ViewModels/Blame.cs index 7ee39550..7cfa8eac 100644 --- a/src/ViewModels/Blame.cs +++ b/src/ViewModels/Blame.cs @@ -1,4 +1,5 @@ -using System.Threading.Tasks; +using System.Collections.Generic; +using System.Threading.Tasks; using Avalonia.Threading; @@ -57,12 +58,18 @@ namespace SourceGit.ViewModels } } - public Models.Commit GetCommitInfo(string commitSHA) + public string GetCommitMessage(string sha) { - return new Commands.QuerySingleCommit(_repo, commitSHA).Result(); + if (_commitMessages.TryGetValue(sha, out var msg)) + return msg; + + msg = new Commands.QueryCommitFullMessage(_repo, sha).Result(); + _commitMessages[sha] = msg; + return msg; } private readonly string _repo; private Models.BlameData _data = null; + private Dictionary _commitMessages = new Dictionary(); } } diff --git a/src/Views/Blame.axaml b/src/Views/Blame.axaml index 4d050bb5..d5c3fd22 100644 --- a/src/Views/Blame.axaml +++ b/src/Views/Blame.axaml @@ -2,7 +2,6 @@ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" - xmlns:m="using:SourceGit.Models" xmlns:vm="using:SourceGit.ViewModels" xmlns:v="using:SourceGit.Views" mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450" @@ -60,21 +59,7 @@ FontFamily="{DynamicResource Fonts.Monospace}" FontSize="{Binding Source={x:Static vm:Preferences.Instance}, Path=EditorFontSize}" TabWidth="{Binding Source={x:Static vm:Preferences.Instance}, Path=EditorTabWidth}" - BlameData="{Binding Data}"> - - - - - - - - - - - - - - + BlameData="{Binding Data}"/> - { - var commit = blame.GetCommitInfo(info.CommitSHA); - if (commit == null) - return; - - Dispatcher.UIThread.Invoke(() => - { - if (IsEffectivelyVisible && IsPointerOver) - { - ToolTip.SetTip(this, commit); - ToolTip.SetIsOpen(this, true); - } - }); - }); + var msg = blame.GetCommitMessage(info.CommitSHA); + ToolTip.SetTip(this, msg); + ToolTip.SetIsOpen(this, true); } return;