enhance: run commit search in background

This commit is contained in:
leo 2024-07-09 15:15:31 +08:00
parent d3f7c31caf
commit c16bed1d9f
No known key found for this signature in database
2 changed files with 45 additions and 18 deletions

View file

@ -259,6 +259,12 @@ namespace SourceGit.ViewModels
}
}
public bool IsSearchLoadingVisible
{
get => _isSearchLoadingVisible;
private set => SetProperty(ref _isSearchLoadingVisible, value);
}
public int SearchCommitFilterType
{
get => _searchCommitFilterType;
@ -533,6 +539,10 @@ namespace SourceGit.ViewModels
if (_histories == null)
return;
IsSearchLoadingVisible = true;
Task.Run(() =>
{
var visible = new List<Models.Commit>();
if (_searchCommitFilterType == 0)
@ -555,7 +565,12 @@ namespace SourceGit.ViewModels
visible = new Commands.QueryCommits(FullPath, $"-1000 -- \"{_searchCommitFilter}\"", false).Result();
}
Dispatcher.UIThread.Invoke(() =>
{
SearchedCommits = visible;
IsSearchLoadingVisible = false;
});
});
}
public void ClearSearchBranchFilter()
@ -1948,6 +1963,7 @@ namespace SourceGit.ViewModels
private object _selectedView = null;
private bool _isSearching = false;
private bool _isSearchLoadingVisible = false;
private int _searchCommitFilterType = 0;
private string _searchCommitFilter = string.Empty;
private List<Models.Commit> _searchedCommits = new List<Models.Commit>();

View file

@ -633,8 +633,19 @@
HorizontalAlignment="Center" VerticalAlignment="Center"
Width="48" Height="48"
Data="{StaticResource Icons.Empty}"
Fill="{DynamicResource Brush.FG2}"
IsVisible="{Binding SearchedCommits.Count, Converter={x:Static c:IntConverters.IsZero}}"/>
Fill="{DynamicResource Brush.FG2}">
<Path.IsVisible>
<MultiBinding Converter="{x:Static BoolConverters.And}">
<Binding Path="SearchedCommits.Count" Converter="{x:Static c:IntConverters.IsZero}"/>
<Binding Path="IsSearchLoadingVisible" Converter="{x:Static BoolConverters.Not}"/>
</MultiBinding>
</Path.IsVisible>
</Path>
<v:LoadingIcon Grid.Row="2"
Width="48" Height="48"
HorizontalAlignment="Center" VerticalAlignment="Center"
IsVisible="{Binding IsSearchLoadingVisible}"/>
</Grid>
</Grid>