/
githubmirror
/
Files
Обзор
Документация
Войти
/
githubmirror
/
Files
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
src/Files.App/Actions/Sidebar/PinFolderToSidebarAction.cs
88 строк
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. using Windows.Storage; namespace Files.App.Actions { [GeneratedRichCommand] internal sealed partial class PinFolderToSidebarAction : ObservableObject, IAction { private readonly IContentPageContext context; private readonly IQuickAccessService service; public string Label => Strings.PinFolderToSidebar.GetLocalizedResource(); public string Description => Strings.PinFolderToSidebarDescription.GetLocalizedFormatResource(context.HasSelection ? context.SelectedItems.Count : 1); public ActionCategory Category => ActionCategory.FileSystem; public RichGlyph Glyph => new(themedIconStyle: "App.ThemedIcons.FavoritePin"); public bool IsExecutable => GetIsExecutable(); public PinFolderToSidebarAction() { context = Ioc.Default.GetRequiredService<IContentPageContext>(); service = Ioc.Default.GetRequiredService<IQuickAccessService>(); context.PropertyChanged += Context_PropertyChanged; App.QuickAccessManager.UpdateQuickAccessWidget += QuickAccessManager_DataChanged; } public async Task ExecuteAsync(object? parameter = null) { if (context.HasSelection) { var items = context.SelectedItems.Select(x => x.ItemPath).ToArray(); await service.PinToSidebarAsync(items); } else if (context.Folder is not null) { await service.PinToSidebarAsync(context.Folder.ItemPath); } } private bool GetIsExecutable() { if (context.PageType == ContentPageTypes.RecycleBin) return false; string[] pinnedFolders = [.. App.QuickAccessManager.Model.PinnedFolders]; return context.HasSelection ? context.SelectedItems.All(IsPinnable) : context.Folder is not null && IsPinnable(context.Folder); bool IsPinnable(ListedItem item) { return item.PrimaryItemAttribute is StorageItemTypes.Folder && !item.IsArchive && !pinnedFolders.Contains(item.ItemPath); } } private void Context_PropertyChanged(object? sender, PropertyChangedEventArgs e) { switch (e.PropertyName) { case nameof(IContentPageContext.Folder): case nameof(IContentPageContext.SelectedItems): OnPropertyChanged(nameof(IsExecutable)); break; } } private void QuickAccessManager_DataChanged(object? sender, ModifyQuickAccessEventArgs e) { OnPropertyChanged(nameof(IsExecutable)); } } }