-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Code Quality: Improved SetAs actions #16480
base: main
Are you sure you want to change the base?
Conversation
src/Files.App/Actions/Content/Background/SetAsLockscreenBackgroundAction.cs
Outdated
Show resolved
Hide resolved
src/Files.App/Actions/Content/Background/SetAsSlideshowBackgroundAction.cs
Outdated
Show resolved
Hide resolved
src/Files.App/Actions/Content/Background/SetAsSlideshowBackgroundAction.cs
Outdated
Show resolved
Hide resolved
src/Files.App/Actions/Content/Background/SetAsWallpaperBackgroundAction.cs
Outdated
Show resolved
Hide resolved
|
||
public override Task ExecuteAsync(object? parameter = null) | ||
{ | ||
if (context.SelectedItem is not null) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@hishitetsu can you confirm if this is okay to remove? I'm pretty sure it's needed to prevent a crash.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, this code is necessary because the item may be deselected between the time it is checked in IsExecutable
and the time the action is actually executed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not use IsExecutable prop instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Certainly, but I noticed we should do the following instead of simply checking to prevent NullReferenceException completely.
if (ContentPageContext.SelectedItem is ListedItem selectedItem)
AppearanceSettingsService.AppThemeBackgroundImageSource = selectedItem.ItemPath;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
Resolved / Related Issues
Steps used to test these changes