Merge pull request #3530 from Flow-Launcher/origin_query_null_issue

Origin query null issue
This commit is contained in:
Jack Ye 2025-05-11 17:59:58 +08:00 committed by GitHub
commit 31c18b81d2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 11 additions and 29 deletions

View file

@ -12,10 +12,7 @@ namespace Flow.Launcher.Storage
internal bool IsTopMost(Result result)
{
// origin query is null when user select the context menu item directly of one item from query list
// in this case, we do not need to check if the result is top most
if (records.IsEmpty || result.OriginQuery == null ||
!records.TryGetValue(result.OriginQuery.RawQuery, out var value))
if (records.IsEmpty || !records.TryGetValue(result.OriginQuery.RawQuery, out var value))
{
return false;
}
@ -26,25 +23,11 @@ namespace Flow.Launcher.Storage
internal void Remove(Result result)
{
// origin query is null when user select the context menu item directly of one item from query list
// in this case, we do not need to remove the record
if (result.OriginQuery == null)
{
return;
}
records.Remove(result.OriginQuery.RawQuery, out _);
}
internal void AddOrUpdate(Result result)
{
// origin query is null when user select the context menu item directly of one item from query list
// in this case, we do not need to add or update the record
if (result.OriginQuery == null)
{
return;
}
var record = new Record
{
PluginID = result.PluginID,

View file

@ -444,12 +444,7 @@ namespace Flow.Launcher.ViewModel
if (QueryResultsSelected())
{
_userSelectedRecord.Add(result);
// origin query is null when user select the context menu item directly of one item from query list
// so we don't want to add it to history
if (result.OriginQuery != null)
{
_history.Add(result.OriginQuery.RawQuery);
}
_history.Add(result.OriginQuery.RawQuery);
lastHistoryIndex = 1;
}
@ -1159,7 +1154,7 @@ namespace Flow.Launcher.ViewModel
{
results = PluginManager.GetContextMenusForPlugin(selected);
results.Add(ContextMenuTopMost(selected));
results.Add(ContextMenuPluginInfo(selected.PluginID));
results.Add(ContextMenuPluginInfo(selected));
}
if (!string.IsNullOrEmpty(query))
@ -1593,7 +1588,8 @@ namespace Flow.Launcher.ViewModel
App.API.ReQuery();
return false;
},
Glyph = new GlyphInfo(FontFamily: "/Resources/#Segoe Fluent Icons", Glyph: "\uE74B")
Glyph = new GlyphInfo(FontFamily: "/Resources/#Segoe Fluent Icons", Glyph: "\uE74B"),
OriginQuery = result.OriginQuery
};
}
else
@ -1610,15 +1606,17 @@ namespace Flow.Launcher.ViewModel
App.API.ReQuery();
return false;
},
Glyph = new GlyphInfo(FontFamily: "/Resources/#Segoe Fluent Icons", Glyph: "\uE74A")
Glyph = new GlyphInfo(FontFamily: "/Resources/#Segoe Fluent Icons", Glyph: "\uE74A"),
OriginQuery = result.OriginQuery
};
}
return menu;
}
private static Result ContextMenuPluginInfo(string id)
private static Result ContextMenuPluginInfo(Result result)
{
var id = result.PluginID;
var metadata = PluginManager.GetPluginForId(id).Metadata;
var translator = App.API;
@ -1640,7 +1638,8 @@ namespace Flow.Launcher.ViewModel
{
App.API.OpenUrl(metadata.Website);
return true;
}
},
OriginQuery = result.OriginQuery
};
return menu;
}