Skip to content

Commit 6ed5308

Browse files
committed
Fix null origin query issue
1 parent fde6b2d commit 6ed5308

File tree

2 files changed

+11
-28
lines changed

2 files changed

+11
-28
lines changed

Flow.Launcher/Storage/TopMostRecord.cs

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,7 @@ public class TopMostRecord
1212

1313
internal bool IsTopMost(Result result)
1414
{
15-
// origin query is null when user select the context menu item directly of one item from query list
16-
// in this case, we do not need to check if the result is top most
17-
if (records.IsEmpty || result.OriginQuery == null ||
15+
if (records.IsEmpty ||
1816
!records.TryGetValue(result.OriginQuery.RawQuery, out var value))
1917
{
2018
return false;
@@ -26,25 +24,11 @@ internal bool IsTopMost(Result result)
2624

2725
internal void Remove(Result result)
2826
{
29-
// origin query is null when user select the context menu item directly of one item from query list
30-
// in this case, we do not need to remove the record
31-
if (result.OriginQuery == null)
32-
{
33-
return;
34-
}
35-
3627
records.Remove(result.OriginQuery.RawQuery, out _);
3728
}
3829

3930
internal void AddOrUpdate(Result result)
4031
{
41-
// origin query is null when user select the context menu item directly of one item from query list
42-
// in this case, we do not need to add or update the record
43-
if (result.OriginQuery == null)
44-
{
45-
return;
46-
}
47-
4832
var record = new Record
4933
{
5034
PluginID = result.PluginID,

Flow.Launcher/ViewModel/MainViewModel.cs

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -444,12 +444,7 @@ private async Task OpenResultAsync(string index)
444444
if (QueryResultsSelected())
445445
{
446446
_userSelectedRecord.Add(result);
447-
// origin query is null when user select the context menu item directly of one item from query list
448-
// so we don't want to add it to history
449-
if (result.OriginQuery != null)
450-
{
451-
_history.Add(result.OriginQuery.RawQuery);
452-
}
447+
_history.Add(result.OriginQuery.RawQuery);
453448
lastHistoryIndex = 1;
454449
}
455450

@@ -1158,7 +1153,7 @@ private void QueryContextMenu()
11581153
{
11591154
results = PluginManager.GetContextMenusForPlugin(selected);
11601155
results.Add(ContextMenuTopMost(selected));
1161-
results.Add(ContextMenuPluginInfo(selected.PluginID));
1156+
results.Add(ContextMenuPluginInfo(selected));
11621157
}
11631158

11641159
if (!string.IsNullOrEmpty(query))
@@ -1592,7 +1587,8 @@ private Result ContextMenuTopMost(Result result)
15921587
App.API.ReQuery();
15931588
return false;
15941589
},
1595-
Glyph = new GlyphInfo(FontFamily: "/Resources/#Segoe Fluent Icons", Glyph: "\uE74B")
1590+
Glyph = new GlyphInfo(FontFamily: "/Resources/#Segoe Fluent Icons", Glyph: "\uE74B"),
1591+
OriginQuery = result.OriginQuery
15961592
};
15971593
}
15981594
else
@@ -1609,15 +1605,17 @@ private Result ContextMenuTopMost(Result result)
16091605
App.API.ReQuery();
16101606
return false;
16111607
},
1612-
Glyph = new GlyphInfo(FontFamily: "/Resources/#Segoe Fluent Icons", Glyph: "\uE74A")
1608+
Glyph = new GlyphInfo(FontFamily: "/Resources/#Segoe Fluent Icons", Glyph: "\uE74A"),
1609+
OriginQuery = result.OriginQuery
16131610
};
16141611
}
16151612

16161613
return menu;
16171614
}
16181615

1619-
private static Result ContextMenuPluginInfo(string id)
1616+
private static Result ContextMenuPluginInfo(Result result)
16201617
{
1618+
var id = result.PluginID;
16211619
var metadata = PluginManager.GetPluginForId(id).Metadata;
16221620
var translator = App.API;
16231621

@@ -1639,7 +1637,8 @@ private static Result ContextMenuPluginInfo(string id)
16391637
{
16401638
App.API.OpenUrl(metadata.Website);
16411639
return true;
1642-
}
1640+
},
1641+
OriginQuery = result.OriginQuery
16431642
};
16441643
return menu;
16451644
}

0 commit comments

Comments
 (0)