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

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

@ -4,19 +4,19 @@ using DiscordChatExporter.Cli.Commands.Shared;
namespace DiscordChatExporter.Cli.Commands.Converters; 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 // Empty or unset value is treated as 'active' to match the previous behavior
if (string.IsNullOrWhiteSpace(rawValue)) if (string.IsNullOrWhiteSpace(rawValue))
return ThreadInclusion.Active; return ThreadInclusionMode.Active;
// Boolean 'true' is treated as 'active', boolean 'false' is treated as 'none' // Boolean 'true' is treated as 'active', boolean 'false' is treated as 'none'
if (bool.TryParse(rawValue, out var boolValue)) 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 // 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( [CommandOption(
"include-threads", "include-threads",
Description = "Which types of threads should be included.", 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( [CommandOption(
"data-package", "data-package",
@ -70,12 +70,12 @@ public class ExportAllCommand : ExportCommandBase
} }
// Threads // Threads
if (ThreadInclusion != ThreadInclusion.None) if (ThreadInclusionMode != ThreadInclusionMode.None)
{ {
await foreach ( await foreach (
var thread in Discord.GetGuildThreadsAsync( var thread in Discord.GetGuildThreadsAsync(
guild.Id, guild.Id,
ThreadInclusion == ThreadInclusion.All, ThreadInclusionMode == ThreadInclusionMode.All,
cancellationToken cancellationToken
) )
) )
@ -132,9 +132,9 @@ public class ExportAllCommand : ExportCommandBase
channels.RemoveAll(c => c.Kind.IsGuild()); channels.RemoveAll(c => c.Kind.IsGuild());
if (!IncludeVoiceChannels) if (!IncludeVoiceChannels)
channels.RemoveAll(c => c.Kind.IsVoice()); channels.RemoveAll(c => c.Kind.IsVoice());
if (ThreadInclusion == ThreadInclusion.None) if (ThreadInclusionMode == ThreadInclusionMode.None)
channels.RemoveAll(c => c.Kind.IsThread()); channels.RemoveAll(c => c.Kind.IsThread());
if (ThreadInclusion != ThreadInclusion.All) if (ThreadInclusionMode != ThreadInclusionMode.All)
channels.RemoveAll(c => c.Kind.IsThread() && c.IsArchived); channels.RemoveAll(c => c.Kind.IsThread() && c.IsArchived);
await ExportAsync(console, channels); await ExportAsync(console, channels);

@ -22,9 +22,9 @@ public class ExportGuildCommand : ExportCommandBase
[CommandOption( [CommandOption(
"include-threads", "include-threads",
Description = "Which types of threads should be included.", 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) public override async ValueTask ExecuteAsync(IConsole console)
{ {
@ -48,12 +48,12 @@ public class ExportGuildCommand : ExportCommandBase
} }
// Threads // Threads
if (ThreadInclusion != ThreadInclusion.None) if (ThreadInclusionMode != ThreadInclusionMode.None)
{ {
await foreach ( await foreach (
var thread in Discord.GetGuildThreadsAsync( var thread in Discord.GetGuildThreadsAsync(
GuildId, GuildId,
ThreadInclusion == ThreadInclusion.All, ThreadInclusionMode == ThreadInclusionMode.All,
cancellationToken cancellationToken
) )
) )

@ -24,9 +24,9 @@ public class GetChannelsCommand : DiscordCommandBase
[CommandOption( [CommandOption(
"include-threads", "include-threads",
Description = "Which types of threads should be included.", 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) public override async ValueTask ExecuteAsync(IConsole console)
{ {
@ -47,11 +47,11 @@ public class GetChannelsCommand : DiscordCommandBase
.FirstOrDefault(); .FirstOrDefault();
var threads = var threads =
ThreadInclusion != ThreadInclusion.None ThreadInclusionMode != ThreadInclusionMode.None
? ( ? (
await Discord.GetGuildThreadsAsync( await Discord.GetGuildThreadsAsync(
GuildId, GuildId,
ThreadInclusion == ThreadInclusion.All, ThreadInclusionMode == ThreadInclusionMode.All,
cancellationToken cancellationToken
) )
) )

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

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

@ -17,7 +17,7 @@ public partial class SettingsService : SettingsBase
public bool IsTokenPersisted { get; set; } = true; 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"; public string DateFormat { get; set; } = "MM/dd/yyyy h:mm tt";

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

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

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

Loading…
Cancel
Save