mirror of
https://github.com/sourcegit-scm/sourcegit.git
synced 2024-12-23 20:47:25 -08:00
enhance: run commit search in background
This commit is contained in:
parent
d3f7c31caf
commit
c16bed1d9f
2 changed files with 45 additions and 18 deletions
|
@ -259,6 +259,12 @@ namespace SourceGit.ViewModels
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool IsSearchLoadingVisible
|
||||||
|
{
|
||||||
|
get => _isSearchLoadingVisible;
|
||||||
|
private set => SetProperty(ref _isSearchLoadingVisible, value);
|
||||||
|
}
|
||||||
|
|
||||||
public int SearchCommitFilterType
|
public int SearchCommitFilterType
|
||||||
{
|
{
|
||||||
get => _searchCommitFilterType;
|
get => _searchCommitFilterType;
|
||||||
|
@ -533,29 +539,38 @@ namespace SourceGit.ViewModels
|
||||||
if (_histories == null)
|
if (_histories == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var visible = new List<Models.Commit>();
|
IsSearchLoadingVisible = true;
|
||||||
|
|
||||||
if (_searchCommitFilterType == 0)
|
Task.Run(() =>
|
||||||
{
|
{
|
||||||
foreach (var c in _histories.Commits)
|
var visible = new List<Models.Commit>();
|
||||||
|
|
||||||
|
if (_searchCommitFilterType == 0)
|
||||||
{
|
{
|
||||||
if (c.SHA.Contains(_searchCommitFilter, StringComparison.OrdinalIgnoreCase)
|
foreach (var c in _histories.Commits)
|
||||||
|| c.Subject.Contains(_searchCommitFilter, StringComparison.OrdinalIgnoreCase)
|
|
||||||
|| c.Author.Name.Contains(_searchCommitFilter, StringComparison.OrdinalIgnoreCase)
|
|
||||||
|| c.Committer.Name.Contains(_searchCommitFilter, StringComparison.OrdinalIgnoreCase)
|
|
||||||
|| c.Author.Email.Contains(_searchCommitFilter, StringComparison.OrdinalIgnoreCase)
|
|
||||||
|| c.Committer.Email.Contains(_searchCommitFilter, StringComparison.OrdinalIgnoreCase))
|
|
||||||
{
|
{
|
||||||
visible.Add(c);
|
if (c.SHA.Contains(_searchCommitFilter, StringComparison.OrdinalIgnoreCase)
|
||||||
|
|| c.Subject.Contains(_searchCommitFilter, StringComparison.OrdinalIgnoreCase)
|
||||||
|
|| c.Author.Name.Contains(_searchCommitFilter, StringComparison.OrdinalIgnoreCase)
|
||||||
|
|| c.Committer.Name.Contains(_searchCommitFilter, StringComparison.OrdinalIgnoreCase)
|
||||||
|
|| c.Author.Email.Contains(_searchCommitFilter, StringComparison.OrdinalIgnoreCase)
|
||||||
|
|| c.Committer.Email.Contains(_searchCommitFilter, StringComparison.OrdinalIgnoreCase))
|
||||||
|
{
|
||||||
|
visible.Add(c);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
else
|
||||||
else
|
{
|
||||||
{
|
visible = new Commands.QueryCommits(FullPath, $"-1000 -- \"{_searchCommitFilter}\"", false).Result();
|
||||||
visible = new Commands.QueryCommits(FullPath, $"-1000 -- \"{_searchCommitFilter}\"", false).Result();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
SearchedCommits = visible;
|
Dispatcher.UIThread.Invoke(() =>
|
||||||
|
{
|
||||||
|
SearchedCommits = visible;
|
||||||
|
IsSearchLoadingVisible = false;
|
||||||
|
});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ClearSearchBranchFilter()
|
public void ClearSearchBranchFilter()
|
||||||
|
@ -1948,6 +1963,7 @@ namespace SourceGit.ViewModels
|
||||||
private object _selectedView = null;
|
private object _selectedView = null;
|
||||||
|
|
||||||
private bool _isSearching = false;
|
private bool _isSearching = false;
|
||||||
|
private bool _isSearchLoadingVisible = false;
|
||||||
private int _searchCommitFilterType = 0;
|
private int _searchCommitFilterType = 0;
|
||||||
private string _searchCommitFilter = string.Empty;
|
private string _searchCommitFilter = string.Empty;
|
||||||
private List<Models.Commit> _searchedCommits = new List<Models.Commit>();
|
private List<Models.Commit> _searchedCommits = new List<Models.Commit>();
|
||||||
|
|
|
@ -633,8 +633,19 @@
|
||||||
HorizontalAlignment="Center" VerticalAlignment="Center"
|
HorizontalAlignment="Center" VerticalAlignment="Center"
|
||||||
Width="48" Height="48"
|
Width="48" Height="48"
|
||||||
Data="{StaticResource Icons.Empty}"
|
Data="{StaticResource Icons.Empty}"
|
||||||
Fill="{DynamicResource Brush.FG2}"
|
Fill="{DynamicResource Brush.FG2}">
|
||||||
IsVisible="{Binding SearchedCommits.Count, Converter={x:Static c:IntConverters.IsZero}}"/>
|
<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>
|
||||||
</Grid>
|
</Grid>
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue