mirror of
https://github.com/Tyrrrz/DiscordChatExporter.git
synced 2026-02-27 03:33:55 +00:00
Enhance output path selection in the GUI
Enables the use of template tokens when exporting multiple channels Closes #676
This commit is contained in:
@@ -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
|
||||
{
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user