Skip to content
Draft
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
39 changes: 25 additions & 14 deletions src/Files.App/Helpers/Navigation/NavigationHelpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,8 @@
public static async Task OpenSelectedItemsAsync(IShellPage associatedInstance, bool openViaApplicationPicker = false)
{
// Don't open files and folders inside recycle bin
if (associatedInstance.ShellViewModel.WorkingDirectory.StartsWith(Constants.UserEnvironmentPaths.RecycleBinPath, StringComparison.Ordinal) ||
if (associatedInstance.ShellViewModel is null ||
associatedInstance.ShellViewModel.WorkingDirectory.StartsWith(Constants.UserEnvironmentPaths.RecycleBinPath, StringComparison.Ordinal) ||
associatedInstance.SlimContentPage?.SelectedItems is null)
{
return;
Expand Down Expand Up @@ -378,7 +379,8 @@
public static async Task OpenItemsWithExecutableAsync(IShellPage associatedInstance, IEnumerable<IStorageItemWithPath> items, string executablePath)
{
// Don't open files and folders inside recycle bin
if (associatedInstance.ShellViewModel.WorkingDirectory.StartsWith(Constants.UserEnvironmentPaths.RecycleBinPath, StringComparison.Ordinal) ||
if (associatedInstance.ShellViewModel is null ||
associatedInstance.ShellViewModel.WorkingDirectory.StartsWith(Constants.UserEnvironmentPaths.RecycleBinPath, StringComparison.Ordinal) ||
associatedInstance.SlimContentPage is null)
return;

Expand All @@ -398,6 +400,9 @@
/// <param name="forceOpenInNewTab">Open folders in a new tab regardless of the "OpenFoldersInNewTab" option</param>
public static async Task<bool> OpenPath(string path, IShellPage associatedInstance, FilesystemItemType? itemType = null, bool openSilent = false, bool openViaApplicationPicker = false, IEnumerable<string>? selectItems = null, string? args = default, bool forceOpenInNewTab = false)
{
if (associatedInstance.ShellViewModel is null)
return false;

string previousDir = associatedInstance.ShellViewModel.WorkingDirectory;
bool isHiddenItem = Win32Helper.HasFileAttribute(path, System.IO.FileAttributes.Hidden);
bool isDirectory = Win32Helper.HasFileAttribute(path, System.IO.FileAttributes.Directory);
Expand Down Expand Up @@ -550,13 +555,16 @@
}
else
{
opened = await associatedInstance.ShellViewModel.GetFolderWithPathFromPathAsync(path)
.OnSuccess((childFolder) =>
{
// Add location to Recent Items List
if (childFolder.Item is SystemStorageFolder)
WindowsRecentItemsService.Add(childFolder.Path);
});
if (associatedInstance.ShellViewModel is not null)
{
opened = await associatedInstance.ShellViewModel.GetFolderWithPathFromPathAsync(path)
.OnSuccess((childFolder) =>
{
// Add location to Recent Items List
if (childFolder.Item is SystemStorageFolder)
WindowsRecentItemsService.Add(childFolder.Path);
});
}
if (!opened)
opened = (FilesystemResult)FolderHelpers.CheckFolderAccessWithWin32(path);

Expand All @@ -582,7 +590,7 @@
}
else
{
if (!FileExtensionHelpers.IsWebLinkFile(path))
if (!FileExtensionHelpers.IsWebLinkFile(path) && associatedInstance.ShellViewModel is not null)
{
StorageFileWithPath childFile = await associatedInstance.ShellViewModel.GetFileWithPathFromPathAsync(shortcutInfo.TargetPath);
// Add location to Recent Items List
Expand All @@ -599,9 +607,11 @@
}
else
{
opened = await associatedInstance.ShellViewModel.GetFileWithPathFromPathAsync(path)
.OnSuccess(async childFile =>
{
if (associatedInstance.ShellViewModel is not null shellViewModel)

Check failure on line 610 in src/Files.App/Helpers/Navigation/NavigationHelpers.cs

View workflow job for this annotation

GitHub Actions / build (Release, x64)

} expected

Check failure on line 610 in src/Files.App/Helpers/Navigation/NavigationHelpers.cs

View workflow job for this annotation

GitHub Actions / build (Release, x64)

; expected

Check failure on line 610 in src/Files.App/Helpers/Navigation/NavigationHelpers.cs

View workflow job for this annotation

GitHub Actions / build (Release, x64)

) expected

Check failure on line 610 in src/Files.App/Helpers/Navigation/NavigationHelpers.cs

View workflow job for this annotation

GitHub Actions / build (Release, arm64)

} expected

Check failure on line 610 in src/Files.App/Helpers/Navigation/NavigationHelpers.cs

View workflow job for this annotation

GitHub Actions / build (Release, arm64)

; expected

Check failure on line 610 in src/Files.App/Helpers/Navigation/NavigationHelpers.cs

View workflow job for this annotation

GitHub Actions / build (Release, arm64)

) expected

Check failure on line 610 in src/Files.App/Helpers/Navigation/NavigationHelpers.cs

View workflow job for this annotation

GitHub Actions / build (Debug, x64)

} expected

Check failure on line 610 in src/Files.App/Helpers/Navigation/NavigationHelpers.cs

View workflow job for this annotation

GitHub Actions / build (Debug, x64)

; expected

Check failure on line 610 in src/Files.App/Helpers/Navigation/NavigationHelpers.cs

View workflow job for this annotation

GitHub Actions / build (Debug, x64)

) expected

Check failure on line 610 in src/Files.App/Helpers/Navigation/NavigationHelpers.cs

View workflow job for this annotation

GitHub Actions / build (Debug, arm64)

} expected

Check failure on line 610 in src/Files.App/Helpers/Navigation/NavigationHelpers.cs

View workflow job for this annotation

GitHub Actions / build (Debug, arm64)

; expected

Check failure on line 610 in src/Files.App/Helpers/Navigation/NavigationHelpers.cs

View workflow job for this annotation

GitHub Actions / build (Debug, arm64)

) expected
{
opened = await shellViewModel.GetFileWithPathFromPathAsync(path)
.OnSuccess(async childFile =>
{
// Add location to Recent Items List
if (childFile.Item is SystemStorageFile)
WindowsRecentItemsService.Add(childFile.Path);
Expand All @@ -627,7 +637,7 @@
bool launchSuccess = false;
BaseStorageFileQueryResult? fileQueryResult = null;
//Get folder to create a file query (to pass to apps like Photos, Movies & TV..., needed to scroll through the folder like what Windows Explorer does)
BaseStorageFolder currentFolder = await associatedInstance.ShellViewModel.GetFolderFromPathAsync(PathNormalization.GetParentDir(path));
BaseStorageFolder currentFolder = await shellViewModel.GetFolderFromPathAsync(PathNormalization.GetParentDir(path));
if (currentFolder is not null)
{
QueryOptions queryOptions = new(CommonFileQuery.DefaultQuery, null);
Expand Down Expand Up @@ -692,6 +702,7 @@
}
}
});
}
}
return opened;
}
Expand Down
Loading