pull/1125/head
Tyrrrz 1 year ago
parent 3740d64601
commit c422ac2351

@ -147,12 +147,10 @@ public abstract class ExportCommandBase : DiscordCommandBase
var isValidOutputPath =
// Anything is valid when exporting a single channel
channels.Count <= 1
||
// When using template tokens, assume the user knows what they're doing
OutputPath.Contains('%')
||
|| OutputPath.Contains('%')
// Otherwise, require an existing directory or an unambiguous directory path
Directory.Exists(OutputPath)
|| Directory.Exists(OutputPath)
|| PathEx.IsDirectoryPath(OutputPath);
if (!isValidOutputPath)

@ -4,19 +4,19 @@ using DiscordChatExporter.Cli.Commands.Shared;
namespace DiscordChatExporter.Cli.Commands.Converters;
internal class ThreadInclusionBindingConverter : BindingConverter<ThreadInclusion>
internal class ThreadInclusionModeBindingConverter : BindingConverter<ThreadInclusionMode>
{
public override ThreadInclusion Convert(string? rawValue)
public override ThreadInclusionMode Convert(string? rawValue)
{
// Empty or unset value is treated as 'active' to match the previous behavior
if (string.IsNullOrWhiteSpace(rawValue))
return ThreadInclusion.Active;
return ThreadInclusionMode.Active;
// Boolean 'true' is treated as 'active', boolean 'false' is treated as 'none'
if (bool.TryParse(rawValue, out var boolValue))
return boolValue ? ThreadInclusion.Active : ThreadInclusion.None;
return boolValue ? ThreadInclusionMode.Active : ThreadInclusionMode.None;
// Otherwise, fall back to regular enum parsing
return Enum.Parse<ThreadInclusion>(rawValue, true);
return Enum.Parse<ThreadInclusionMode>(rawValue, true);
}
}

@ -30,9 +30,9 @@ public class ExportAllCommand : ExportCommandBase
[CommandOption(
"include-threads",
Description = "Which types of threads should be included.",
Converter = typeof(ThreadInclusionBindingConverter)
Converter = typeof(ThreadInclusionModeBindingConverter)
)]
public ThreadInclusion ThreadInclusion { get; init; } = ThreadInclusion.None;
public ThreadInclusionMode ThreadInclusionMode { get; init; } = ThreadInclusionMode.None;
[CommandOption(
"data-package",
@ -70,12 +70,12 @@ public class ExportAllCommand : ExportCommandBase
}
// Threads
if (ThreadInclusion != ThreadInclusion.None)
if (ThreadInclusionMode != ThreadInclusionMode.None)
{
await foreach (
var thread in Discord.GetGuildThreadsAsync(
guild.Id,
ThreadInclusion == ThreadInclusion.All,
ThreadInclusionMode == ThreadInclusionMode.All,
cancellationToken
)
)
@ -132,9 +132,9 @@ public class ExportAllCommand : ExportCommandBase
channels.RemoveAll(c => c.Kind.IsGuild());
if (!IncludeVoiceChannels)
channels.RemoveAll(c => c.Kind.IsVoice());
if (ThreadInclusion == ThreadInclusion.None)
if (ThreadInclusionMode == ThreadInclusionMode.None)
channels.RemoveAll(c => c.Kind.IsThread());
if (ThreadInclusion != ThreadInclusion.All)
if (ThreadInclusionMode != ThreadInclusionMode.All)
channels.RemoveAll(c => c.Kind.IsThread() && c.IsArchived);
await ExportAsync(console, channels);

@ -22,9 +22,9 @@ public class ExportGuildCommand : ExportCommandBase
[CommandOption(
"include-threads",
Description = "Which types of threads should be included.",
Converter = typeof(ThreadInclusionBindingConverter)
Converter = typeof(ThreadInclusionModeBindingConverter)
)]
public ThreadInclusion ThreadInclusion { get; init; } = ThreadInclusion.None;
public ThreadInclusionMode ThreadInclusionMode { get; init; } = ThreadInclusionMode.None;
public override async ValueTask ExecuteAsync(IConsole console)
{
@ -48,12 +48,12 @@ public class ExportGuildCommand : ExportCommandBase
}
// Threads
if (ThreadInclusion != ThreadInclusion.None)
if (ThreadInclusionMode != ThreadInclusionMode.None)
{
await foreach (
var thread in Discord.GetGuildThreadsAsync(
GuildId,
ThreadInclusion == ThreadInclusion.All,
ThreadInclusionMode == ThreadInclusionMode.All,
cancellationToken
)
)

@ -24,9 +24,9 @@ public class GetChannelsCommand : DiscordCommandBase
[CommandOption(
"include-threads",
Description = "Which types of threads should be included.",
Converter = typeof(ThreadInclusionBindingConverter)
Converter = typeof(ThreadInclusionModeBindingConverter)
)]
public ThreadInclusion ThreadInclusion { get; init; } = ThreadInclusion.None;
public ThreadInclusionMode ThreadInclusionMode { get; init; } = ThreadInclusionMode.None;
public override async ValueTask ExecuteAsync(IConsole console)
{
@ -47,11 +47,11 @@ public class GetChannelsCommand : DiscordCommandBase
.FirstOrDefault();
var threads =
ThreadInclusion != ThreadInclusion.None
ThreadInclusionMode != ThreadInclusionMode.None
? (
await Discord.GetGuildThreadsAsync(
GuildId,
ThreadInclusion == ThreadInclusion.All,
ThreadInclusionMode == ThreadInclusionMode.All,
cancellationToken
)
)

@ -1,6 +1,6 @@
namespace DiscordChatExporter.Cli.Commands.Shared;
public enum ThreadInclusion
public enum ThreadInclusionMode
{
None,
Active,

@ -1,6 +1,6 @@
namespace DiscordChatExporter.Gui.Models;
public enum ThreadInclusion
public enum ThreadInclusionMode
{
None,
Active,

@ -17,7 +17,7 @@ public partial class SettingsService : SettingsBase
public bool IsTokenPersisted { get; set; } = true;
public ThreadInclusion ThreadInclusion { get; set; } = ThreadInclusion.None;
public ThreadInclusionMode ThreadInclusionMode { get; set; } = ThreadInclusionMode.None;
public string DateFormat { get; set; } = "MM/dd/yyyy h:mm tt";

@ -170,12 +170,12 @@ public class DashboardViewModel : PropertyChangedBase
}
// Threads
if (_settingsService.ThreadInclusion != ThreadInclusion.None)
if (_settingsService.ThreadInclusionMode != ThreadInclusionMode.None)
{
await foreach (
var thread in _discord.GetGuildThreadsAsync(
SelectedGuild.Id,
_settingsService.ThreadInclusion == ThreadInclusion.All
_settingsService.ThreadInclusionMode == ThreadInclusionMode.All
)
)
{

@ -28,13 +28,13 @@ public class SettingsViewModel : DialogScreen
set => _settingsService.IsTokenPersisted = value;
}
public IReadOnlyList<ThreadInclusion> AvailableThreadInclusions { get; } =
Enum.GetValues<ThreadInclusion>();
public IReadOnlyList<ThreadInclusionMode> AvailableThreadInclusions { get; } =
Enum.GetValues<ThreadInclusionMode>();
public ThreadInclusion ThreadInclusion
public ThreadInclusionMode ThreadInclusionMode
{
get => _settingsService.ThreadInclusion;
set => _settingsService.ThreadInclusion = value;
get => _settingsService.ThreadInclusionMode;
set => _settingsService.ThreadInclusionMode = value;
}
public string DateFormat

@ -82,7 +82,7 @@
IsChecked="{Binding IsTokenPersisted}" />
</DockPanel>
<!-- Thread inclusion -->
<!-- Thread inclusion mode -->
<DockPanel
Margin="16,8"
Background="Transparent"
@ -96,7 +96,7 @@
VerticalAlignment="Center"
DockPanel.Dock="Right"
ItemsSource="{Binding AvailableThreadInclusions}"
SelectedItem="{Binding ThreadInclusion}" />
SelectedItem="{Binding ThreadInclusionMode}" />
</DockPanel>
<!-- Date format -->

Loading…
Cancel
Save