Skip to content

Commit cd13e85

Browse files
Fix: Display error dialog for file tag application failure on UI thread
1 parent 823e87d commit cd13e85

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

src/Files.App/Utils/FileTags/FileTagsHelper.cs

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

4+
using Files.App.Extensions;
45
using Microsoft.UI.Xaml.Controls;
56
using Windows.Foundation.Metadata;
67
using Windows.Storage;
@@ -40,17 +41,20 @@ public static async void WriteFileTag(string filePath, string[] tag)
4041
var result = Win32Helper.WriteStringToFile($"{filePath}:files", string.Join(',', tag));
4142
if (result == false)
4243
{
43-
ContentDialog dialog = new()
44+
await MainWindow.Instance.DispatcherQueue.EnqueueOrInvokeAsync(async () =>
4445
{
45-
Title = Strings.ErrorApplyingTagTitle.GetLocalizedResource(),
46-
Content = Strings.ErrorApplyingTagContent.GetLocalizedResource(),
47-
PrimaryButtonText = "Ok".GetLocalizedResource()
48-
};
46+
ContentDialog dialog = new()
47+
{
48+
Title = Strings.ErrorApplyingTagTitle.GetLocalizedResource(),
49+
Content = Strings.ErrorApplyingTagContent.GetLocalizedResource(),
50+
PrimaryButtonText = "Ok".GetLocalizedResource()
51+
};
4952

50-
if (ApiInformation.IsApiContractPresent("Windows.Foundation.UniversalApiContract", 8))
51-
dialog.XamlRoot = MainWindow.Instance.Content.XamlRoot;
53+
if (ApiInformation.IsApiContractPresent("Windows.Foundation.UniversalApiContract", 8))
54+
dialog.XamlRoot = MainWindow.Instance.Content.XamlRoot;
5255

53-
await dialog.TryShowAsync();
56+
await dialog.TryShowAsync();
57+
});
5458
}
5559
}
5660
if (isReadOnly) // Restore read-only attribute (#7534)

0 commit comments

Comments
 (0)