Enhance output path selection in the GUI

Enables the use of template tokens when exporting multiple channels
Closes #676
This commit is contained in:
Tyrrrz
2023-02-13 19:48:57 +02:00
parent f1ae0266f1
commit c8d83beb8d
5 changed files with 115 additions and 25 deletions

View File

@@ -158,22 +158,27 @@ public class DashboardViewModel : PropertyChangedBase
var exporter = new ChannelExporter(_discord);
var progresses = Enumerable
.Range(0, dialog.Channels!.Count)
.Select(_ => _progressMuxer.CreateInput())
var channelProgressPairs = dialog
.Channels!
.Select(c => new
{
Channel = c,
Progress = _progressMuxer.CreateInput()
})
.ToArray();
var successfulExportCount = 0;
await Parallel.ForEachAsync(
dialog.Channels.Zip(progresses),
channelProgressPairs,
new ParallelOptions
{
MaxDegreeOfParallelism = Math.Max(1, _settingsService.ParallelLimit)
},
async (tuple, cancellationToken) =>
async (pair, cancellationToken) =>
{
var (channel, progress) = tuple;
var channel = pair.Channel;
var progress = pair.Progress;
try
{

View File

@@ -86,15 +86,8 @@ public class ExportSetupViewModel : DialogScreen
public void ToggleAdvancedSection() => IsAdvancedSectionDisplayed = !IsAdvancedSectionDisplayed;
public void Confirm()
public void ShowOutputPathPrompt()
{
// Persist preferences
_settingsService.LastExportFormat = SelectedFormat;
_settingsService.LastPartitionLimitValue = PartitionLimitValue;
_settingsService.LastMessageFilterValue = MessageFilterValue;
_settingsService.LastShouldDownloadAssets = ShouldDownloadAssets;
// If single channel - prompt file path
if (IsSingleChannel)
{
var defaultFileName = ExportRequest.GetDefaultOutputFileName(
@@ -105,20 +98,26 @@ public class ExportSetupViewModel : DialogScreen
Before?.Pipe(Snowflake.FromDate)
);
// Filter
var ext = SelectedFormat.GetFileExtension();
var filter = $"{ext.ToUpperInvariant()} files|*.{ext}";
var extension = SelectedFormat.GetFileExtension();
var filter = $"{extension.ToUpperInvariant()} files|*.{extension}";
OutputPath = _dialogManager.PromptSaveFilePath(filter, defaultFileName);
}
// If multiple channels - prompt dir path
else
{
OutputPath = _dialogManager.PromptDirectoryPath();
}
}
if (string.IsNullOrWhiteSpace(OutputPath))
return;
public bool CanConfirm => !string.IsNullOrWhiteSpace(OutputPath);
public void Confirm()
{
// Persist preferences
_settingsService.LastExportFormat = SelectedFormat;
_settingsService.LastPartitionLimitValue = PartitionLimitValue;
_settingsService.LastMessageFilterValue = MessageFilterValue;
_settingsService.LastShouldDownloadAssets = ShouldDownloadAssets;
Close(true);
}