Skip to content

Fix: Fixed issue where removing an item from the recent list didn't work #12273

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

Merged
merged 1 commit into from
May 4, 2023
Merged
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
14 changes: 11 additions & 3 deletions src/Files.App/Shell/ContextMenu.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@ public async Task<bool> InvokeVerb(string? verb)
if (string.IsNullOrEmpty(verb))
return false;

var item = Items.Where(x => x.CommandString == verb).FirstOrDefault();
if (item is not null && item.ID >= 0)
// Prefer invocation by ID
return await InvokeItem(item.ID);

try
{
var currentWindows = Win32API.GetDesktopWindows();
Expand All @@ -73,10 +78,10 @@ public async Task<bool> InvokeVerb(string? verb)
return false;
}

public async Task InvokeItem(int itemID)
public async Task<bool> InvokeItem(int itemID)
{
if (itemID < 0)
return;
return false;

try
{
Expand All @@ -90,13 +95,16 @@ public async Task InvokeItem(int itemID)
pici.cbSize = (uint)Marshal.SizeOf(pici);

await owningThread.PostMethod(() => cMenu.InvokeCommand(pici));

Win32API.BringToForeground(currentWindows);

return true;
}
catch (Exception ex) when (ex is COMException or UnauthorizedAccessException)
{
Debug.WriteLine(ex);
}

return false;
}

#region FactoryMethods
Expand Down