Skip to content

Fix: Fixed issue where "Send To" submenu was sometimes not displayed on widgets #12093

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
Apr 17, 2023
Merged
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
8 changes: 4 additions & 4 deletions src/Files.App/BaseLayout.cs
Original file line number Diff line number Diff line change
Expand Up @@ -800,7 +800,7 @@ private async Task AddShellMenuItemsAsync(List<ContextMenuFlyoutItemViewModel> s
var openWith = contextMenuFlyout.SecondaryCommands.FirstOrDefault(x => x is AppBarButton abb && (abb.Tag as string) == "OpenWith") as AppBarButton;
if (openWithMenuItem?.LoadSubMenuAction is not null && openWithOverflow is not null && openWith is not null)
{
await openWithMenuItem.LoadSubMenuAction.Invoke();
await openWithMenuItem.LoadSubMenuAction();
var openWithSubItems = ItemModelListToContextFlyoutHelper.GetMenuFlyoutItemsFromModel(ShellContextmenuHelper.GetOpenWithItems(shellMenuItems));

if (openWithSubItems is not null)
Expand All @@ -824,7 +824,7 @@ private async Task AddShellMenuItemsAsync(List<ContextMenuFlyoutItemViewModel> s
var sendTo = contextMenuFlyout.SecondaryCommands.FirstOrDefault(x => x is AppBarButton abb && (abb.Tag as string) == "SendTo") as AppBarButton;
if (sendToMenuItem?.LoadSubMenuAction is not null && sendToOverflow is not null && sendTo is not null)
{
await sendToMenuItem.LoadSubMenuAction.Invoke();
await sendToMenuItem.LoadSubMenuAction();
var sendToSubItems = ItemModelListToContextFlyoutHelper.GetMenuFlyoutItemsFromModel(ShellContextmenuHelper.GetSendToItems(shellMenuItems));

if (sendToSubItems is not null)
Expand All @@ -844,14 +844,14 @@ private async Task AddShellMenuItemsAsync(List<ContextMenuFlyoutItemViewModel> s

// Add items to main shell submenu
mainShellMenuItems.Where(x => x.LoadSubMenuAction is not null).ForEach(async x => {
await x.LoadSubMenuAction.Invoke();
await x.LoadSubMenuAction();

ShellContextmenuHelper.AddItemsToMainMenu(mainItems, x);
});

// Add items to overflow shell submenu
overflowShellMenuItems.Where(x => x.LoadSubMenuAction is not null).ForEach(async x => {
await x.LoadSubMenuAction.Invoke();
await x.LoadSubMenuAction();

ShellContextmenuHelper.AddItemsToOverflowMenu(overflowItem, x);
});
Expand Down
10 changes: 5 additions & 5 deletions src/Files.App/Helpers/ShellContextMenuHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -309,9 +309,9 @@ public static async Task LoadShellMenuItems(
}

// Add items to openwith dropdown
if (openWithItem is not null)
if (openWithItem?.LoadSubMenuAction is not null)
{
await openWithItem.LoadSubMenuAction.Invoke();
await openWithItem.LoadSubMenuAction();

openWithItem.OpacityIcon = new OpacityIconModel()
{
Expand All @@ -325,9 +325,9 @@ public static async Task LoadShellMenuItems(
}

// Add items to sendto dropdown
if (sendToItem is not null)
if (sendToItem?.LoadSubMenuAction is not null)
{
await sendToItem.LoadSubMenuAction.Invoke();
await sendToItem.LoadSubMenuAction();

var (_, sendToItems) = ItemModelListToContextFlyoutHelper.GetAppBarItemsFromModel(new List<ContextMenuFlyoutItemViewModel>() { sendToItem });
var placeholder = itemContextMenuFlyout.SecondaryCommands.Where(x => Equals((x as AppBarButton)?.Tag, "SendToPlaceholder")).FirstOrDefault() as AppBarButton;
Expand All @@ -338,7 +338,7 @@ public static async Task LoadShellMenuItems(

// Add items to shell submenu
shellMenuItems.Where(x => x.LoadSubMenuAction is not null).ForEach(async x => {
await x.LoadSubMenuAction.Invoke();
await x.LoadSubMenuAction();

if (!UserSettingsService.GeneralSettingsService.MoveShellExtensionsToSubMenu)
{
Expand Down
2 changes: 1 addition & 1 deletion src/Files.App/Shell/ContextMenu.cs
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ public async Task<bool> LoadSubMenu(List<Win32ContextMenuItem> subItems)
{
try
{
loadSubMenuAction!.Invoke();
loadSubMenuAction!();
}
catch (COMException)
{
Expand Down