Skip to content

Commit 31c18b8

Browse files
authored
Merge pull request #3530 from Flow-Launcher/origin_query_null_issue
Origin query null issue
2 parents 1b2b49a + 0e6741c commit 31c18b8

File tree

2 files changed

+11
-29
lines changed

2 files changed

+11
-29
lines changed

Flow.Launcher/Storage/TopMostRecord.cs

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +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 ||
18-
!records.TryGetValue(result.OriginQuery.RawQuery, out var value))
15+
if (records.IsEmpty || !records.TryGetValue(result.OriginQuery.RawQuery, out var value))
1916
{
2017
return false;
2118
}
@@ -26,25 +23,11 @@ internal bool IsTopMost(Result result)
2623

2724
internal void Remove(Result result)
2825
{
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-
3626
records.Remove(result.OriginQuery.RawQuery, out _);
3727
}
3828

3929
internal void AddOrUpdate(Result result)
4030
{
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-
4831
var record = new Record
4932
{
5033
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

@@ -1159,7 +1154,7 @@ private void QueryContextMenu()
11591154
{
11601155
results = PluginManager.GetContextMenusForPlugin(selected);
11611156
results.Add(ContextMenuTopMost(selected));
1162-
results.Add(ContextMenuPluginInfo(selected.PluginID));
1157+
results.Add(ContextMenuPluginInfo(selected));
11631158
}
11641159

11651160
if (!string.IsNullOrEmpty(query))
@@ -1593,7 +1588,8 @@ private Result ContextMenuTopMost(Result result)
15931588
App.API.ReQuery();
15941589
return false;
15951590
},
1596-
Glyph = new GlyphInfo(FontFamily: "/Resources/#Segoe Fluent Icons", Glyph: "\uE74B")
1591+
Glyph = new GlyphInfo(FontFamily: "/Resources/#Segoe Fluent Icons", Glyph: "\uE74B"),
1592+
OriginQuery = result.OriginQuery
15971593
};
15981594
}
15991595
else
@@ -1610,15 +1606,17 @@ private Result ContextMenuTopMost(Result result)
16101606
App.API.ReQuery();
16111607
return false;
16121608
},
1613-
Glyph = new GlyphInfo(FontFamily: "/Resources/#Segoe Fluent Icons", Glyph: "\uE74A")
1609+
Glyph = new GlyphInfo(FontFamily: "/Resources/#Segoe Fluent Icons", Glyph: "\uE74A"),
1610+
OriginQuery = result.OriginQuery
16141611
};
16151612
}
16161613

16171614
return menu;
16181615
}
16191616

1620-
private static Result ContextMenuPluginInfo(string id)
1617+
private static Result ContextMenuPluginInfo(Result result)
16211618
{
1619+
var id = result.PluginID;
16221620
var metadata = PluginManager.GetPluginForId(id).Metadata;
16231621
var translator = App.API;
16241622

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

0 commit comments

Comments
 (0)