mirror of
https://github.com/Tyrrrz/DiscordChatExporter.git
synced 2026-03-31 17:43:04 -06:00
GUI: simplify double-tap handler to call ExportCommand directly
Co-authored-by: Tyrrrz <1935960+Tyrrrz@users.noreply.github.com>
This commit is contained in:
parent
c2ee6f047d
commit
3bbff8b20a
|
|
@ -223,54 +223,6 @@ public partial class DashboardViewModel : ViewModelBase
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[RelayCommand]
|
|
||||||
private async Task ShowSetupIfSingleChannelAsync()
|
|
||||||
{
|
|
||||||
// Wait for any in-progress channel loading to complete
|
|
||||||
if (IsBusy)
|
|
||||||
{
|
|
||||||
var tcs = new TaskCompletionSource();
|
|
||||||
|
|
||||||
void Handler(object? _, System.ComponentModel.PropertyChangedEventArgs e)
|
|
||||||
{
|
|
||||||
if (e.PropertyName == nameof(IsBusy) && !IsBusy)
|
|
||||||
tcs.TrySetResult();
|
|
||||||
}
|
|
||||||
|
|
||||||
PropertyChanged += Handler;
|
|
||||||
|
|
||||||
// Re-check after subscribing to avoid missing the transition
|
|
||||||
if (!IsBusy)
|
|
||||||
{
|
|
||||||
PropertyChanged -= Handler;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
await tcs.Task;
|
|
||||||
}
|
|
||||||
finally
|
|
||||||
{
|
|
||||||
PropertyChanged -= Handler;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Only auto-export when there is exactly one child-less (non-category) channel
|
|
||||||
if (
|
|
||||||
AvailableChannels is not { Count: 1 }
|
|
||||||
|| AvailableChannels[0].Children.Count != 0
|
|
||||||
|| AvailableChannels[0].Channel.IsCategory
|
|
||||||
)
|
|
||||||
return;
|
|
||||||
|
|
||||||
SelectedChannels.Clear();
|
|
||||||
SelectedChannels.Add(AvailableChannels[0]);
|
|
||||||
|
|
||||||
await ExportAsync();
|
|
||||||
}
|
|
||||||
|
|
||||||
private bool CanExport() =>
|
private bool CanExport() =>
|
||||||
!IsBusy && _discord is not null && SelectedGuild is not null && SelectedChannels.Any();
|
!IsBusy && _discord is not null && SelectedGuild is not null && SelectedChannels.Any();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -23,8 +23,20 @@ public partial class DashboardView : UserControl<DashboardViewModel>
|
||||||
SelectionChangedEventArgs args
|
SelectionChangedEventArgs args
|
||||||
) => DataContext.PullChannelsCommand.Execute(null);
|
) => DataContext.PullChannelsCommand.Execute(null);
|
||||||
|
|
||||||
private void AvailableGuildsListBox_OnDoubleTapped(object? sender, TappedEventArgs args) =>
|
private void AvailableGuildsListBox_OnDoubleTapped(object? sender, TappedEventArgs args)
|
||||||
DataContext.ShowSetupIfSingleChannelCommand.Execute(null);
|
{
|
||||||
|
// Only works when there is exactly one non-category, child-less channel
|
||||||
|
if (
|
||||||
|
DataContext.AvailableChannels is not { Count: 1 }
|
||||||
|
|| DataContext.AvailableChannels[0].Channel.IsCategory
|
||||||
|
|| DataContext.AvailableChannels[0].Children.Count != 0
|
||||||
|
)
|
||||||
|
return;
|
||||||
|
|
||||||
|
DataContext.SelectedChannels.Clear();
|
||||||
|
DataContext.SelectedChannels.Add(DataContext.AvailableChannels[0]);
|
||||||
|
DataContext.ExportCommand.Execute(null);
|
||||||
|
}
|
||||||
|
|
||||||
private void AvailableChannelsTreeView_OnSelectionChanged(
|
private void AvailableChannelsTreeView_OnSelectionChanged(
|
||||||
object? sender,
|
object? sender,
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue