GUI: simplify double-tap handler to call ExportCommand directly

Co-authored-by: Tyrrrz <1935960+Tyrrrz@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot] 2026-02-27 16:19:45 +00:00
parent c2ee6f047d
commit 3bbff8b20a
2 changed files with 14 additions and 50 deletions

View file

@ -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() =>
!IsBusy && _discord is not null && SelectedGuild is not null && SelectedChannels.Any();

View file

@ -23,8 +23,20 @@ public partial class DashboardView : UserControl<DashboardViewModel>
SelectionChangedEventArgs args
) => DataContext.PullChannelsCommand.Execute(null);
private void AvailableGuildsListBox_OnDoubleTapped(object? sender, TappedEventArgs args) =>
DataContext.ShowSetupIfSingleChannelCommand.Execute(null);
private void AvailableGuildsListBox_OnDoubleTapped(object? sender, TappedEventArgs args)
{
// 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(
object? sender,