Code Quality: Use RichCommands in home and sidebar
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.
- Open Files app
- Right click widget item (use those three commands)
- Right click sidebar item (again)
Confirmed it's working
Are the sidebar contexts hidden from the command palette and actions page?
Ouch, I forgot to do that, will do.
Done
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()
Did you click Open command immediately after context menu opened?
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.
This should help unblock #4262
What's the latest on this PR?
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
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.
The same problem exists in the sidebar, although it doesn't crash.
Ah then this is fixed in widget?
Ah then this is fixed in widget?
Yes👍
Nice! Thank you for checking.
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.
Fixed
@0x5bfa can you resolve the merge conflicts?