/
githubmirror
/
Files
Обзор
Документация
Войти
/
githubmirror
/
Files
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
src/Files.App/Actions/Start/PinToStartAction.cs
67 строк
2 KB
yair100
Fix: Fixed an issue where folder related actions were enabled for archives (#18745)
19 июл 2026, 23:32
Не верифицирован
19 июл 2026, 23:32
4fc8795
Код
Авторство
О чём код?
// Copyright (c) Files Community // Licensed under the MIT License. namespace Files.App.Actions { [GeneratedRichCommand] internal sealed class PinToStartAction : IAction { private IStorageService StorageService { get; } = Ioc.Default.GetRequiredService<IStorageService>(); private IStartMenuService StartMenuService { get; } = Ioc.Default.GetRequiredService<IStartMenuService>(); public IContentPageContext context; public string Label => Strings.PinItemToStartText.GetLocalizedResource(); public string Description => Strings.PinToStartDescription.GetLocalizedFormatResource(context.HasSelection ? context.SelectedItems.Count : 1); public RichGlyph Glyph => new(themedIconStyle: "App.ThemedIcons.FavoritePin"); public ActionCategory Category => ActionCategory.Start; public bool IsExecutable => context.ShellPage is not null; public PinToStartAction() { context = Ioc.Default.GetRequiredService<IContentPageContext>(); } public async Task ExecuteAsync(object? parameter = null) { if (context.SelectedItems.Count > 0 && context.ShellPage?.SlimContentPage?.SelectedItems is not null) { foreach (ListedItem listedItem in context.ShellPage.SlimContentPage.SelectedItems) { await SafetyExtensions.IgnoreExceptions(async () => { IStorable storable = listedItem switch { // Archives are marked as folders when browsable in-app but are files on disk { IsFolder: true, IsArchive: false } => await StorageService.GetFolderAsync(listedItem.ItemPath), _ => await StorageService.GetFileAsync((listedItem as IShortcutItem)?.TargetPath ?? listedItem.ItemPath) }; await StartMenuService.PinAsync(storable, listedItem.Name); }); } } else if (context.ShellPage?.ShellViewModel?.CurrentFolder is not null) { await SafetyExtensions.IgnoreExceptions(async () => { var currentFolder = context.ShellPage.ShellViewModel.CurrentFolder; IStorable storable = context.PageType is ContentPageTypes.ZipFolder ? await StorageService.GetFileAsync(currentFolder.ItemPath) : await StorageService.GetFolderAsync(currentFolder.ItemPath); await StartMenuService.PinAsync(storable, currentFolder.Name); }); } } } }