Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New results model #1787

Draft
wants to merge 3 commits into
base: dev
Choose a base branch
from
Draft
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
1 change: 1 addition & 0 deletions Flow.Launcher/Flow.Launcher.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@

<ItemGroup>
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.0.0" />
<PackageReference Include="DynamicData" Version="7.12.11" />
<PackageReference Include="Fody" Version="6.5.4">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
Expand Down
4 changes: 2 additions & 2 deletions Flow.Launcher/ResultListBox.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
d:DesignWidth="100"
Focusable="False"
IsSynchronizedWithCurrentItem="True"
ItemsSource="{Binding Results}"
ItemsSource="{Binding Display}"
KeyboardNavigation.DirectionalNavigation="Cycle"
PreviewMouseDown="ListBox_PreviewMouseDown"
PreviewMouseLeftButtonDown="ResultList_PreviewMouseLeftButtonDown"
Expand All @@ -26,7 +26,7 @@
SelectionMode="Single"
Style="{DynamicResource BaseListboxStyle}"
VirtualizingStackPanel.IsVirtualizing="True"
VirtualizingStackPanel.VirtualizationMode="Standard"
VirtualizingStackPanel.VirtualizationMode="Recycling"
Visibility="{Binding Visibility}"
mc:Ignorable="d">
<!-- IsSynchronizedWithCurrentItem: http://stackoverflow.com/a/7833798/2833083 -->
Expand Down
8 changes: 4 additions & 4 deletions Flow.Launcher/ViewModel/MainViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ private void RegisterResultsUpdatedEvent()
var token = e.Token == default ? _updateToken : e.Token;

PluginManager.UpdatePluginMetadata(e.Results, pair.Metadata, e.Query);
if (!_resultsUpdateChannelWriter.TryWrite(new ResultsForUpdate(e.Results, pair.Metadata, e.Query, token)))
if (!_resultsUpdateChannelWriter.TryWrite(new ResultsForUpdate(e.Results, pair.Metadata, token)))
{
Log.Error("MainViewModel", "Unable to add item to Result Update Queue");
}
Expand Down Expand Up @@ -710,7 +710,7 @@ private async void QueryResults()
if (query == null) // shortcut expanded
{
Results.Clear();
Results.Visibility = Visibility.Collapsed;
// Results.Visibility = Visibility.Collapsed;
PluginIconPath = null;
SearchIconVisibility = Visibility.Visible;
return;
Expand Down Expand Up @@ -814,7 +814,7 @@ async Task QueryTask(PluginPair plugin)

results ??= _emptyResult;

if (!_resultsUpdateChannelWriter.TryWrite(new ResultsForUpdate(results, plugin.Metadata, query, currentCancellationToken)))
if (!_resultsUpdateChannelWriter.TryWrite(new ResultsForUpdate(results, plugin.Metadata, currentCancellationToken)))
{
Log.Error("MainViewModel", "Unable to add item to Result Update Queue");
}
Expand Down Expand Up @@ -1042,7 +1042,7 @@ public void Save()
/// <summary>
/// To avoid deadlock, this method should not called from main thread
/// </summary>
public void UpdateResultView(IEnumerable<ResultsForUpdate> resultsForUpdates)
public void UpdateResultView(ICollection<ResultsForUpdate> resultsForUpdates)
{
if (!resultsForUpdates.Any())
return;
Expand Down
4 changes: 1 addition & 3 deletions Flow.Launcher/ViewModel/ResultsForUpdate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,12 @@ public struct ResultsForUpdate
public PluginMetadata Metadata { get; }
public string ID { get; }

public Query Query { get; }
public CancellationToken Token { get; }

public ResultsForUpdate(IReadOnlyList<Result> results, PluginMetadata metadata, Query query, CancellationToken token)
public ResultsForUpdate(IReadOnlyList<Result> results, PluginMetadata metadata, CancellationToken token)
{
Results = results;
Metadata = metadata;
Query = query;
Token = token;
ID = metadata.ID;
}
Expand Down
Loading