/
githubmirror
/
Files
Обзор
Документация
Войти
/
githubmirror
/
Files
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
src/Files.App/Actions/Start/UnpinFromStartAction.cs
64 строки
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 UnpinFromStartAction : IAction { private IStorageService StorageService { get; } = Ioc.Default.GetRequiredService<IStorageService>(); private IStartMenuService StartMenuService { get; } = Ioc.Default.GetRequiredService<IStartMenuService>(); public IContentPageContext context; public string Label => Strings.UnpinItemFromStartText.GetLocalizedResource(); public string Description => Strings.UnpinFromStartDescription.GetLocalizedFormatResource(context.HasSelection ? context.SelectedItems.Count : 1); public RichGlyph Glyph => new(themedIconStyle: "App.ThemedIcons.FavoritePinRemove"); public ActionCategory Category => ActionCategory.Start; public UnpinFromStartAction() { context = Ioc.Default.GetRequiredService<IContentPageContext>(); } public async Task ExecuteAsync(object? parameter = null) { if (context.SelectedItems.Count > 0) { 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.UnpinAsync(storable); }); } } else { 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.UnpinAsync(storable); }); } } } }