You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
26 lines
710 B
26 lines
710 B
using System.Threading.Tasks;
|
|
using CommunityToolkit.Mvvm.ComponentModel;
|
|
using CommunityToolkit.Mvvm.Input;
|
|
|
|
namespace DiscordChatExporter.Gui.Framework;
|
|
|
|
public abstract partial class DialogViewModelBase<T> : ViewModelBase
|
|
{
|
|
private readonly TaskCompletionSource<T> _closeTcs =
|
|
new(TaskCreationOptions.RunContinuationsAsynchronously);
|
|
|
|
[ObservableProperty]
|
|
private T? _dialogResult;
|
|
|
|
[RelayCommand]
|
|
protected void Close(T dialogResult)
|
|
{
|
|
DialogResult = dialogResult;
|
|
_closeTcs.TrySetResult(dialogResult);
|
|
}
|
|
|
|
public async Task<T> WaitForCloseAsync() => await _closeTcs.Task;
|
|
}
|
|
|
|
public abstract class DialogViewModelBase : DialogViewModelBase<bool?>;
|