Files icon indicating copy to clipboard operation
Files copied to clipboard

Code Quality: Use RichCommands in home and sidebar

Open 0x5bfa opened this issue 1 year ago • 3 comments

Resolved / Related Issues

To prevent extra work, all changes to the Files codebase must link to an approved issue marked as Ready to build. Please insert the issue number following the hashtag with the issue number that this Pull Request resolves.

  • Related #14760

Steps used to test these changes

Stability is a top priority for Files and all changes are required to go through testing before being merged into the repo. Please include a list of steps that you used to test this PR.

  1. Open Files app
  2. Right click widget item (use those three commands)
  3. Right click sidebar item (again)

Confirmed it's working image

0x5bfa avatar May 07 '24 16:05 0x5bfa

Are the sidebar contexts hidden from the command palette and actions page?

yaira2 avatar May 07 '24 20:05 yaira2

Ouch, I forgot to do that, will do.

0x5bfa avatar May 08 '24 06:05 0x5bfa

Done

0x5bfa avatar May 09 '24 00:05 0x5bfa

Still occasionally crashes when opening tabs or panes from the home page.

2024-06-02 22:28:52.3068|Error|System.NullReferenceException: Object reference not set to an instance of an object.
   at Files.App.Actions.OpenInNewPaneFromHomeAction.ExecuteAsync(Object parameter)
   at Files.App.Data.Commands.ActionCommand.Execute(Object parameter)
   at System.Threading.Tasks.Task.<>c.<ThrowAsync>b__128_0(Object state)
   at Microsoft.UI.Dispatching.DispatcherQueueSynchronizationContext.<>c__DisplayClass2_0.<Post>b__0()
2024-06-02 22:30:06.9409|Error|System.NullReferenceException: Object reference not set to an instance of an object.
   at Files.App.Actions.OpenInNewTabFromHomeAction.ExecuteAsync(Object parameter)
   at Files.App.Data.Commands.ActionCommand.Execute(Object parameter)
   at System.Threading.Tasks.Task.<>c.<ThrowAsync>b__128_0(Object state)
   at Microsoft.UI.Dispatching.DispatcherQueueSynchronizationContext.<>c__DisplayClass2_0.<Post>b__0()

hishitetsu avatar Jun 02 '24 13:06 hishitetsu

Did you click Open command immediately after context menu opened?

0x5bfa avatar Jun 02 '24 22:06 0x5bfa

Did you click Open command immediately after context menu opened?

No, I didn't. I don't know under what conditions this occurs, but I don't think the null check is a fundamental solution since it occurred during normal operation.

hishitetsu avatar Jun 03 '24 06:06 hishitetsu

This should help unblock #4262

yaira2 avatar Jun 04 '24 00:06 yaira2

What's the latest on this PR?

yaira2 avatar Jun 04 '24 00:06 yaira2

Still occasionally crashes when opening tabs or panes from the home page.

This problem hasn't been resolved. @0x5bfa put a null check, but I think the action may still not work just not crash. https://github.com/files-community/Files/pull/15329#issuecomment-2143856697

hishitetsu avatar Jun 04 '24 00:06 hishitetsu

I tracked down the cause of crashes. If you right-click on one item and then right-click on another item without closing the first context menu, the item set in the opening event will be overwritten to null in the first context menu's closed event. I don't think we should clear HomePageContext.RightClickedItem when the context menu has been closed because it may make HomePageContext.RightClickedItem null during the action.

hishitetsu avatar Jun 04 '24 08:06 hishitetsu

The same problem exists in the sidebar, although it doesn't crash.

hishitetsu avatar Jun 07 '24 11:06 hishitetsu

Ah then this is fixed in widget?

0x5bfa avatar Jun 07 '24 12:06 0x5bfa

Ah then this is fixed in widget?

Yes👍

hishitetsu avatar Jun 07 '24 12:06 hishitetsu

Nice! Thank you for checking.

0x5bfa avatar Jun 07 '24 12:06 0x5bfa

I found another issue. When I right-click a sidebar section title (Pinned, Drivers, etc.), Open in commands appear and the home page will open when executing them. The commands should not appear.

hishitetsu avatar Jun 07 '24 12:06 hishitetsu

Fixed

0x5bfa avatar Jun 07 '24 13:06 0x5bfa

@0x5bfa can you resolve the merge conflicts?

yaira2 avatar Jun 09 '24 17:06 yaira2