mirror of
https://github.com/Tyrrrz/DiscordChatExporter.git
synced 2025-05-24 03:36:52 -04:00
Disable whole UI when busy
This commit is contained in:
parent
1850caba71
commit
8ac8c16db3
3 changed files with 7 additions and 11 deletions
|
@ -20,8 +20,6 @@ namespace DiscordChatExporter.Services
|
|||
|
||||
private async Task ExportAsTextAsync(string filePath, ChannelChatLog log)
|
||||
{
|
||||
var dateFormat = _settingsService.DateFormat;
|
||||
|
||||
using (var writer = new StreamWriter(filePath, false, Encoding.UTF8, 128 * 1024))
|
||||
{
|
||||
// Generation info
|
||||
|
@ -39,7 +37,7 @@ namespace DiscordChatExporter.Services
|
|||
// Chat log
|
||||
foreach (var group in log.MessageGroups)
|
||||
{
|
||||
var timeStampFormatted = group.TimeStamp.ToString(dateFormat);
|
||||
var timeStampFormatted = group.TimeStamp.ToString(_settingsService.DateFormat);
|
||||
await writer.WriteLineAsync($"{group.Author} [{timeStampFormatted}]");
|
||||
|
||||
// Messages
|
||||
|
@ -66,8 +64,6 @@ namespace DiscordChatExporter.Services
|
|||
|
||||
private async Task ExportAsHtmlAsync(string filePath, ChannelChatLog log, string css)
|
||||
{
|
||||
var dateFormat = _settingsService.DateFormat;
|
||||
|
||||
using (var writer = new StreamWriter(filePath, false, Encoding.UTF8, 128 * 1024))
|
||||
{
|
||||
// Generation info
|
||||
|
@ -113,7 +109,7 @@ namespace DiscordChatExporter.Services
|
|||
await writer.WriteAsync($"<span class=\"msg-user\" title=\"{HtmlEncode(group.Author)}\">");
|
||||
await writer.WriteAsync(HtmlEncode(group.Author.Name));
|
||||
await writer.WriteLineAsync("</span>");
|
||||
var timeStampFormatted = HtmlEncode(group.TimeStamp.ToString(dateFormat));
|
||||
var timeStampFormatted = HtmlEncode(group.TimeStamp.ToString(_settingsService.DateFormat));
|
||||
await writer.WriteLineAsync($"<span class=\"msg-date\">{timeStampFormatted}</span>");
|
||||
|
||||
// Messages
|
||||
|
@ -130,7 +126,7 @@ namespace DiscordChatExporter.Services
|
|||
if (message.EditedTimeStamp != null)
|
||||
{
|
||||
var editedTimeStampFormatted =
|
||||
HtmlEncode(message.EditedTimeStamp.Value.ToString(dateFormat));
|
||||
HtmlEncode(message.EditedTimeStamp.Value.ToString(_settingsService.DateFormat));
|
||||
await writer.WriteAsync(
|
||||
$"<span class=\"msg-edited\" title=\"{editedTimeStampFormatted}\">(edited)</span>");
|
||||
}
|
||||
|
|
|
@ -15,7 +15,6 @@ namespace DiscordChatExporter.Services
|
|||
|
||||
public IReadOnlyList<MessageGroup> GroupMessages(IReadOnlyList<Message> messages)
|
||||
{
|
||||
var groupLimit = _settingsService.MessageGroupLimit;
|
||||
var result = new List<MessageGroup>();
|
||||
|
||||
// Group adjacent messages by timestamp and author
|
||||
|
@ -31,7 +30,7 @@ namespace DiscordChatExporter.Services
|
|||
message.Author.Id != groupFirst.Author.Id ||
|
||||
(message.TimeStamp - groupFirst.TimeStamp).TotalHours > 1 ||
|
||||
message.TimeStamp.Hour != groupFirst.TimeStamp.Hour ||
|
||||
groupBuffer.Count >= groupLimit
|
||||
groupBuffer.Count >= _settingsService.MessageGroupLimit
|
||||
);
|
||||
|
||||
// If condition is true - flush buffer
|
||||
|
|
|
@ -20,6 +20,9 @@ Window "DiscordChatExporter.Views.MainWindow" {
|
|||
|
||||
DialogHost {
|
||||
DockPanel {
|
||||
IsEnabled: bind IsBusy
|
||||
convert (bool b) => b ? false : true
|
||||
|
||||
// Toolbar
|
||||
Border {
|
||||
DockPanel.Dock: Top
|
||||
|
@ -100,8 +103,6 @@ Window "DiscordChatExporter.Views.MainWindow" {
|
|||
Grid {
|
||||
DockPanel {
|
||||
Background: resource dyn "MaterialDesignCardBackground"
|
||||
IsEnabled: bind IsBusy
|
||||
convert (bool b) => b ? false : true
|
||||
Visibility: bind IsDataAvailable
|
||||
convert (bool b) => b ? Visibility.Visible : Visibility.Hidden
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue