Skip to content

Commit 5fc74c7

Browse files
authored
Fix: Fixed warnings in settings (#13968)
1 parent 5103a62 commit 5fc74c7

File tree

3 files changed

+10
-7
lines changed

3 files changed

+10
-7
lines changed

src/Files.App/Data/Models/FolderSettingsViewModel.cs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -326,15 +326,17 @@ public static void SetLayoutPreferencesForPath(string folderPath, LayoutPreferen
326326
if (!userSettingsService.FoldersSettingsService.SyncFolderPreferencesAcrossDirectories)
327327
{
328328
var folderFRN = NativeFileOperationsHelper.GetFolderFRN(folderPath);
329-
WriteLayoutPreferencesToDb(folderPath.TrimPath(), folderFRN, prefs);
329+
var trimmedFolderPath = folderPath.TrimPath();
330+
if (trimmedFolderPath is not null)
331+
WriteLayoutPreferencesToDb(trimmedFolderPath, folderFRN, prefs);
330332
}
331333
else
332334
{
333335
userSettingsService.FoldersSettingsService.DefaultLayoutMode = prefs.LayoutMode;
334336
userSettingsService.LayoutSettingsService.DefaultGridViewSize = prefs.GridViewSize;
335337

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

461463
if (folderPath == Constants.UserEnvironmentPaths.DownloadsPath)
462464
// Default for downloads folder is to group by date created
463-
return new LayoutPreferences() {
465+
return new LayoutPreferences()
466+
{
464467
DirectoryGroupOption = GroupOption.DateCreated,
465468
DirectoryGroupDirection = SortDirection.Descending,
466469
DirectoryGroupByDateUnit = GroupByDateUnit.Year

src/Files.App/ViewModels/Settings/AboutViewModel.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public class AboutViewModel : ObservableObject
2525
public ICommand OpenPrivacyPolicyCommand { get; }
2626
public ICommand OpenCrowdinCommand { get; }
2727

28-
private string _ThirdPartyNotices;
28+
private string _ThirdPartyNotices = string.Empty;
2929
public string ThirdPartyNotices
3030
{
3131
get => _ThirdPartyNotices;

src/Files.App/ViewModels/Settings/AdvancedViewModel.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
// Copyright (c) 2023 Files Community
22
// Licensed under the MIT License. See the LICENSE.
33

4-
using Files.App.Utils.Shell;
54
using Microsoft.Extensions.Logging;
65
using Microsoft.Win32;
76
using SevenZip;
@@ -18,7 +17,7 @@ namespace Files.App.ViewModels.Settings
1817
public class AdvancedViewModel : ObservableObject
1918
{
2019
private IUserSettingsService UserSettingsService { get; } = Ioc.Default.GetRequiredService<IUserSettingsService>();
21-
20+
2221
private readonly IFileTagsSettingsService fileTagsSettingsService = Ioc.Default.GetRequiredService<IFileTagsSettingsService>();
2322

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

0 commit comments

Comments
 (0)