Disable whole UI when busy

pull/17/head
Alexey Golub 7 years ago
parent 1850caba71
commit 8ac8c16db3

@ -20,8 +20,6 @@ namespace DiscordChatExporter.Services
private async Task ExportAsTextAsync(string filePath, ChannelChatLog log) private async Task ExportAsTextAsync(string filePath, ChannelChatLog log)
{ {
var dateFormat = _settingsService.DateFormat;
using (var writer = new StreamWriter(filePath, false, Encoding.UTF8, 128 * 1024)) using (var writer = new StreamWriter(filePath, false, Encoding.UTF8, 128 * 1024))
{ {
// Generation info // Generation info
@ -39,7 +37,7 @@ namespace DiscordChatExporter.Services
// Chat log // Chat log
foreach (var group in log.MessageGroups) 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}]"); await writer.WriteLineAsync($"{group.Author} [{timeStampFormatted}]");
// Messages // Messages
@ -66,8 +64,6 @@ namespace DiscordChatExporter.Services
private async Task ExportAsHtmlAsync(string filePath, ChannelChatLog log, string css) 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)) using (var writer = new StreamWriter(filePath, false, Encoding.UTF8, 128 * 1024))
{ {
// Generation info // Generation info
@ -113,7 +109,7 @@ namespace DiscordChatExporter.Services
await writer.WriteAsync($"<span class=\"msg-user\" title=\"{HtmlEncode(group.Author)}\">"); await writer.WriteAsync($"<span class=\"msg-user\" title=\"{HtmlEncode(group.Author)}\">");
await writer.WriteAsync(HtmlEncode(group.Author.Name)); await writer.WriteAsync(HtmlEncode(group.Author.Name));
await writer.WriteLineAsync("</span>"); 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>"); await writer.WriteLineAsync($"<span class=\"msg-date\">{timeStampFormatted}</span>");
// Messages // Messages
@ -130,7 +126,7 @@ namespace DiscordChatExporter.Services
if (message.EditedTimeStamp != null) if (message.EditedTimeStamp != null)
{ {
var editedTimeStampFormatted = var editedTimeStampFormatted =
HtmlEncode(message.EditedTimeStamp.Value.ToString(dateFormat)); HtmlEncode(message.EditedTimeStamp.Value.ToString(_settingsService.DateFormat));
await writer.WriteAsync( await writer.WriteAsync(
$"<span class=\"msg-edited\" title=\"{editedTimeStampFormatted}\">(edited)</span>"); $"<span class=\"msg-edited\" title=\"{editedTimeStampFormatted}\">(edited)</span>");
} }

@ -15,7 +15,6 @@ namespace DiscordChatExporter.Services
public IReadOnlyList<MessageGroup> GroupMessages(IReadOnlyList<Message> messages) public IReadOnlyList<MessageGroup> GroupMessages(IReadOnlyList<Message> messages)
{ {
var groupLimit = _settingsService.MessageGroupLimit;
var result = new List<MessageGroup>(); var result = new List<MessageGroup>();
// Group adjacent messages by timestamp and author // Group adjacent messages by timestamp and author
@ -31,7 +30,7 @@ namespace DiscordChatExporter.Services
message.Author.Id != groupFirst.Author.Id || message.Author.Id != groupFirst.Author.Id ||
(message.TimeStamp - groupFirst.TimeStamp).TotalHours > 1 || (message.TimeStamp - groupFirst.TimeStamp).TotalHours > 1 ||
message.TimeStamp.Hour != groupFirst.TimeStamp.Hour || message.TimeStamp.Hour != groupFirst.TimeStamp.Hour ||
groupBuffer.Count >= groupLimit groupBuffer.Count >= _settingsService.MessageGroupLimit
); );
// If condition is true - flush buffer // If condition is true - flush buffer

@ -20,6 +20,9 @@ Window "DiscordChatExporter.Views.MainWindow" {
DialogHost { DialogHost {
DockPanel { DockPanel {
IsEnabled: bind IsBusy
convert (bool b) => b ? false : true
// Toolbar // Toolbar
Border { Border {
DockPanel.Dock: Top DockPanel.Dock: Top
@ -100,8 +103,6 @@ Window "DiscordChatExporter.Views.MainWindow" {
Grid { Grid {
DockPanel { DockPanel {
Background: resource dyn "MaterialDesignCardBackground" Background: resource dyn "MaterialDesignCardBackground"
IsEnabled: bind IsBusy
convert (bool b) => b ? false : true
Visibility: bind IsDataAvailable Visibility: bind IsDataAvailable
convert (bool b) => b ? Visibility.Visible : Visibility.Hidden convert (bool b) => b ? Visibility.Visible : Visibility.Hidden

Loading…
Cancel
Save