Optimize thread inclusion UX across GUI and CLI

Related to #1119
This commit is contained in:
Tyrrrz
2023-08-28 22:08:51 +03:00
parent d430f77ae1
commit 3740d64601
9 changed files with 49 additions and 79 deletions

View File

@@ -0,0 +1,8 @@
namespace DiscordChatExporter.Gui.Models;
public enum ThreadInclusion
{
None,
Active,
All
}

View File

@@ -2,6 +2,7 @@
using System.IO;
using Cogwheel;
using DiscordChatExporter.Core.Exporting;
using DiscordChatExporter.Gui.Models;
using Microsoft.Win32;
namespace DiscordChatExporter.Gui.Services;
@@ -16,9 +17,7 @@ public partial class SettingsService : SettingsBase
public bool IsTokenPersisted { get; set; } = true;
public bool ShouldShowThreads { get; set; }
public bool ShouldShowArchivedThreads { get; set; }
public ThreadInclusion ThreadInclusion { get; set; } = ThreadInclusion.None;
public string DateFormat { get; set; } = "MM/dd/yyyy h:mm tt";

View File

@@ -8,6 +8,7 @@ using DiscordChatExporter.Core.Discord.Data;
using DiscordChatExporter.Core.Exceptions;
using DiscordChatExporter.Core.Exporting;
using DiscordChatExporter.Core.Utils.Extensions;
using DiscordChatExporter.Gui.Models;
using DiscordChatExporter.Gui.Services;
using DiscordChatExporter.Gui.Utils;
using DiscordChatExporter.Gui.ViewModels.Dialogs;
@@ -169,12 +170,12 @@ public class DashboardViewModel : PropertyChangedBase
}
// Threads
if (_settingsService.ShouldShowThreads)
if (_settingsService.ThreadInclusion != ThreadInclusion.None)
{
await foreach (
var thread in _discord.GetGuildThreadsAsync(
SelectedGuild.Id,
_settingsService.ShouldShowArchivedThreads
_settingsService.ThreadInclusion == ThreadInclusion.All
)
)
{

View File

@@ -1,4 +1,6 @@
using System;
using System.Collections.Generic;
using DiscordChatExporter.Gui.Models;
using DiscordChatExporter.Gui.Services;
using DiscordChatExporter.Gui.ViewModels.Framework;
@@ -26,23 +28,13 @@ public class SettingsViewModel : DialogScreen
set => _settingsService.IsTokenPersisted = value;
}
public bool ShouldShowThreads
{
get => _settingsService.ShouldShowThreads;
set => _settingsService.ShouldShowThreads = value;
}
public IReadOnlyList<ThreadInclusion> AvailableThreadInclusions { get; } =
Enum.GetValues<ThreadInclusion>();
public bool ShouldShowArchivedThreads
public ThreadInclusion ThreadInclusion
{
get => _settingsService.ShouldShowArchivedThreads;
set
{
_settingsService.ShouldShowArchivedThreads = value;
// Enabling archived threads implicitly enables threads
if (value)
ShouldShowThreads = true;
}
get => _settingsService.ThreadInclusion;
set => _settingsService.ThreadInclusion = value;
}
public string DateFormat

View File

@@ -82,36 +82,21 @@
IsChecked="{Binding IsTokenPersisted}" />
</DockPanel>
<!-- Show threads -->
<!-- Thread inclusion -->
<DockPanel
Margin="16,8"
Background="Transparent"
LastChildFill="False"
ToolTip="Pull threads and show them in the channel list">
ToolTip="Which types of threads to show in the channel list">
<TextBlock
VerticalAlignment="Center"
DockPanel.Dock="Left"
Text="Show threads" />
<ToggleButton
<ComboBox
VerticalAlignment="Center"
DockPanel.Dock="Right"
IsChecked="{Binding ShouldShowThreads}" />
</DockPanel>
<!-- Show archived threads -->
<DockPanel
Margin="16,8"
Background="Transparent"
LastChildFill="False"
ToolTip="Pull archived threads and show them in the channel list">
<TextBlock
VerticalAlignment="Center"
DockPanel.Dock="Left"
Text="Show archived threads" />
<ToggleButton
VerticalAlignment="Center"
DockPanel.Dock="Right"
IsChecked="{Binding ShouldShowArchivedThreads}" />
ItemsSource="{Binding AvailableThreadInclusions}"
SelectedItem="{Binding ThreadInclusion}" />
</DockPanel>
<!-- Date format -->