Skip to content

Fix: Fixed warnings in settings #13968

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

Merged
merged 1 commit into from
Nov 20, 2023
Merged
Show file tree
Hide file tree
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
9 changes: 6 additions & 3 deletions src/Files.App/Data/Models/FolderSettingsViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -326,15 +326,17 @@ public static void SetLayoutPreferencesForPath(string folderPath, LayoutPreferen
if (!userSettingsService.FoldersSettingsService.SyncFolderPreferencesAcrossDirectories)
{
var folderFRN = NativeFileOperationsHelper.GetFolderFRN(folderPath);
WriteLayoutPreferencesToDb(folderPath.TrimPath(), folderFRN, prefs);
var trimmedFolderPath = folderPath.TrimPath();
if (trimmedFolderPath is not null)
WriteLayoutPreferencesToDb(trimmedFolderPath, folderFRN, prefs);
}
else
{
userSettingsService.FoldersSettingsService.DefaultLayoutMode = prefs.LayoutMode;
userSettingsService.LayoutSettingsService.DefaultGridViewSize = prefs.GridViewSize;

// Do not save options which only work in recycle bin or cloud folders or search results as global
if (prefs.DirectorySortOption != SortOption.Path &&
if (prefs.DirectorySortOption != SortOption.Path &&
prefs.DirectorySortOption != SortOption.OriginalFolder &&
prefs.DirectorySortOption != SortOption.DateDeleted &&
prefs.DirectorySortOption != SortOption.SyncStatus)
Expand Down Expand Up @@ -460,7 +462,8 @@ private static LayoutPreferences GetDefaultLayoutPreferences(string folderPath)

if (folderPath == Constants.UserEnvironmentPaths.DownloadsPath)
// Default for downloads folder is to group by date created
return new LayoutPreferences() {
return new LayoutPreferences()
{
DirectoryGroupOption = GroupOption.DateCreated,
DirectoryGroupDirection = SortDirection.Descending,
DirectoryGroupByDateUnit = GroupByDateUnit.Year
Expand Down
2 changes: 1 addition & 1 deletion src/Files.App/ViewModels/Settings/AboutViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public class AboutViewModel : ObservableObject
public ICommand OpenPrivacyPolicyCommand { get; }
public ICommand OpenCrowdinCommand { get; }

private string _ThirdPartyNotices;
private string _ThirdPartyNotices = string.Empty;
public string ThirdPartyNotices
{
get => _ThirdPartyNotices;
Expand Down
6 changes: 3 additions & 3 deletions src/Files.App/ViewModels/Settings/AdvancedViewModel.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// Copyright (c) 2023 Files Community
// Licensed under the MIT License. See the LICENSE.

using Files.App.Utils.Shell;
using Microsoft.Extensions.Logging;
using Microsoft.Win32;
using SevenZip;
Expand All @@ -18,7 +17,7 @@ namespace Files.App.ViewModels.Settings
public class AdvancedViewModel : ObservableObject
{
private IUserSettingsService UserSettingsService { get; } = Ioc.Default.GetRequiredService<IUserSettingsService>();

private readonly IFileTagsSettingsService fileTagsSettingsService = Ioc.Default.GetRequiredService<IFileTagsSettingsService>();

public ICommand SetAsDefaultExplorerCommand { get; }
Expand Down Expand Up @@ -93,7 +92,8 @@ private async Task SetAsDefaultExplorerAsync()
try
{
using var regProcess = Process.Start(new ProcessStartInfo("regedit.exe", @$"/s ""{Path.Combine(destFolder, IsSetAsDefaultFileManager ? "SetFilesAsDefault.reg" : "UnsetFilesAsDefault.reg")}""") { UseShellExecute = true, Verb = "runas" });
await regProcess.WaitForExitAsync();
if (regProcess is not null)
await regProcess.WaitForExitAsync();
}
catch
{
Expand Down