Skip to content

Conversation

@hishitetsu
Copy link
Member

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.

  • Closes #

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. Opened Files ...
  2. ...

public void CheckForBackgroundImage()
{
var filesAppSection = DesktopIni.FirstOrDefault(x => x.SectionName == "FilesApp");
var filesAppSection = DesktopIni?.FirstOrDefault(x => x.SectionName == "FilesApp");
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@0x5bfa I found that LayoutModeChangeRequested() might call this method before desktop.ini was loaded, so I added a null-safe operator to ignore the call.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we add the loader inside this method? This doesn't make much sense since even if ini file exists you'll have to reload until it's loaded

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

EnumerateItemsFromStandardFolderAsync should always load desktop.ini when the folder is successfully loaded, so I don't think it is necessary to load it every time.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct me if I'm wrong

once this desktop background check method called ahead of time, the background is still null. So unless you don't refresh and pray that desktop ini data is loaded first, the background won't be loaded.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CheckForBackgroundImage is called without loaded desktop.ini if LayoutModeChangeRequested is called before the folder load is completed or after the folder load fails. But the former will always call GetDesktopIniFileData and CheckForBackgroundImage in EnumerateItemsFromStandardFolderAsync, and the latter is an error state and can be ignored.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dang. Should we set a setter to call CheckForBackgroundImage in the property?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's one way. I don't have a preference.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the Folder background has a fade in transition, then you can load the folder view, and once the contents are done loading, you can then check and fade in the folder image, if there is an ini file. Lazy load essentially.


await OrderFilesAndFoldersAsync();
await ApplyFilesAndFoldersChangesAsync();
await dispatcherQueue.EnqueueOrInvokeAsync(CheckForSolutionFile, Microsoft.UI.Dispatching.DispatcherQueuePriority.Low);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CheckForSolutionFile is not related to GetDesktopIniFileData and CheckForBackgroundImage, so I separated the queuing.

@hishitetsu hishitetsu added the ready for review Pull requests that are ready for review label Jul 13, 2024
Copy link
Member

@yaira2 yaira2 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@yaira2 yaira2 added ready to merge Pull requests that are approved and ready to merge and removed ready for review Pull requests that are ready for review labels Jul 14, 2024
@yaira2 yaira2 changed the title Fix: Fixed ArgumentNullException in ShellViewModel.CheckForBackgroundImage() Code Quality: Fixed ArgumentNullException in ShellViewModel.CheckForBackgroundImage() Jul 14, 2024
@yaira2 yaira2 merged commit a77620f into files-community:main Jul 14, 2024
@hishitetsu hishitetsu deleted the FixArgumentNullException branch July 14, 2024 03:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready to merge Pull requests that are approved and ready to merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants