Skip to content

Commit 426bd67

Browse files
authored
Code Quality: Follow up for Fixed DirectoryNotFoundException when pinning items (#15872)
1 parent 47be2f0 commit 426bd67

File tree

2 files changed

+14
-13
lines changed

2 files changed

+14
-13
lines changed

src/Files.App/Actions/Start/PinToStartAction.cs

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

4-
using CommunityToolkit.Mvvm.DependencyInjection;
5-
using Files.Core.Storage;
6-
74
namespace Files.App.Actions
85
{
96
internal sealed class PinToStartAction : IAction
@@ -45,15 +42,18 @@ await SafetyExtensions.IgnoreExceptions(async () =>
4542
_ => await StorageService.GetFileAsync((listedItem as ShortcutItem)?.TargetPath ?? listedItem.ItemPath)
4643
};
4744
await StartMenuService.PinAsync(storable, listedItem.Name);
48-
});
45+
});
4946
}
5047
}
5148
else if (context.ShellPage?.ShellViewModel?.CurrentFolder is not null)
5249
{
53-
var currentFolder = context.ShellPage.ShellViewModel.CurrentFolder;
54-
var folder = await StorageService.GetFolderAsync(currentFolder.ItemPath);
50+
await SafetyExtensions.IgnoreExceptions(async () =>
51+
{
52+
var currentFolder = context.ShellPage.ShellViewModel.CurrentFolder;
53+
var folder = await StorageService.GetFolderAsync(currentFolder.ItemPath);
5554

56-
await StartMenuService.PinAsync(folder, currentFolder.Name);
55+
await StartMenuService.PinAsync(folder, currentFolder.Name);
56+
});
5757
}
5858
}
5959
}

src/Files.App/Actions/Start/UnpinFromStartAction.cs

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

4-
using Files.Core.Storage;
5-
64
namespace Files.App.Actions
75
{
86
internal sealed class UnpinFromStartAction : IAction
@@ -41,15 +39,18 @@ await SafetyExtensions.IgnoreExceptions(async () =>
4139
_ => await StorageService.GetFileAsync((listedItem as ShortcutItem)?.TargetPath ?? listedItem.ItemPath)
4240
};
4341
await StartMenuService.UnpinAsync(storable);
44-
});
42+
});
4543
}
4644
}
4745
else
4846
{
49-
var currentFolder = context.ShellPage.ShellViewModel.CurrentFolder;
50-
var folder = await StorageService.GetFolderAsync(currentFolder.ItemPath);
47+
await SafetyExtensions.IgnoreExceptions(async () =>
48+
{
49+
var currentFolder = context.ShellPage.ShellViewModel.CurrentFolder;
50+
var folder = await StorageService.GetFolderAsync(currentFolder.ItemPath);
5151

52-
await StartMenuService.UnpinAsync(folder);
52+
await StartMenuService.UnpinAsync(folder);
53+
});
5354
}
5455
}
5556
}

0 commit comments

Comments
 (0)