make OnTextChanged async

for some reason before this change the program would stop responding if
  a non-existing path was chosen in the file picker. Maybe the
  .GetAwaiter().GetResult() trick does not work correctly with
  exceptions...
This commit is contained in:
2026-03-01 19:42:54 +03:00
parent 7436748057
commit 175b67b22d

View File

@@ -3,6 +3,7 @@ using Avalonia.Controls;
using Avalonia.Interactivity; using Avalonia.Interactivity;
using Avalonia.Platform.Storage; using Avalonia.Platform.Storage;
using System; using System;
using System.Threading.Tasks;
namespace KeyKeeper.Views namespace KeyKeeper.Views
{ {
@@ -23,7 +24,7 @@ namespace KeyKeeper.Views
ConfirmPasswordBox.TextChanged += OnPasswordTextChanged; ConfirmPasswordBox.TextChanged += OnPasswordTextChanged;
} }
private void OnTextChanged(object? sender, TextChangedEventArgs e) private async void OnTextChanged(object? sender, TextChangedEventArgs e)
{ {
UpdateCreateButtonState(); UpdateCreateButtonState();
PathWarning.Text = ""; PathWarning.Text = "";
@@ -34,7 +35,7 @@ namespace KeyKeeper.Views
try try
{ {
var storageFile = StorageProvider.TryGetFileFromPathAsync(path).GetAwaiter().GetResult(); var storageFile = await StorageProvider.TryGetFileFromPathAsync(path);
if (storageFile != null) if (storageFile != null)
{ {
PathWarning.Text = "File already exists. It will be overwritten."; PathWarning.Text = "File already exists. It will be overwritten.";