From c01b9d0e5fb59857711c470bcf7a9d3110d7c693 Mon Sep 17 00:00:00 2001 From: Alexey Golub Date: Thu, 28 Sep 2017 20:21:00 +0300 Subject: [PATCH] Don't disable everything when busy --- DiscordChatExporter/ViewModels/MainViewModel.cs | 14 ++++++-------- DiscordChatExporter/Views/MainWindow.ammy | 5 ++--- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/DiscordChatExporter/ViewModels/MainViewModel.cs b/DiscordChatExporter/ViewModels/MainViewModel.cs index 43cbbd0..7aac1aa 100644 --- a/DiscordChatExporter/ViewModels/MainViewModel.cs +++ b/DiscordChatExporter/ViewModels/MainViewModel.cs @@ -21,10 +21,10 @@ namespace DiscordChatExporter.ViewModels private readonly Dictionary> _guildChannelsMap; private bool _isBusy; - private IReadOnlyList _availableGuilds; private Guild _selectedGuild; private IReadOnlyList _availableChannels; + private string _cachedToken; public bool IsBusy { @@ -102,26 +102,24 @@ namespace DiscordChatExporter.ViewModels private async void PullData() { IsBusy = true; + _cachedToken = Token; // Clear existing _guildChannelsMap.Clear(); - AvailableGuilds = new Guild[0]; - AvailableChannels = new Channel[0]; - SelectedGuild = null; // Get DM channels { - var channels = await _dataService.GetDirectMessageChannelsAsync(Token); + var channels = await _dataService.GetDirectMessageChannelsAsync(_cachedToken); var guild = new Guild("@me", "Direct Messages", null); _guildChannelsMap[guild] = channels.ToArray(); } // Get guild channels { - var guilds = await _dataService.GetGuildsAsync(Token); + var guilds = await _dataService.GetGuildsAsync(_cachedToken); foreach (var guild in guilds) { - var channels = await _dataService.GetGuildChannelsAsync(Token, guild.Id); + var channels = await _dataService.GetGuildChannelsAsync(_cachedToken, guild.Id); channels = channels.Where(c => c.Type == ChannelType.GuildTextChat); _guildChannelsMap[guild] = channels.ToArray(); } @@ -155,7 +153,7 @@ namespace DiscordChatExporter.ViewModels } // Get messages - var messages = await _dataService.GetChannelMessagesAsync(Token, channel.Id); + var messages = await _dataService.GetChannelMessagesAsync(_cachedToken, channel.Id); // Create log var chatLog = new ChannelChatLog(SelectedGuild, channel, messages); diff --git a/DiscordChatExporter/Views/MainWindow.ammy b/DiscordChatExporter/Views/MainWindow.ammy index cbbc5c1..38562c3 100644 --- a/DiscordChatExporter/Views/MainWindow.ammy +++ b/DiscordChatExporter/Views/MainWindow.ammy @@ -20,9 +20,6 @@ Window "DiscordChatExporter.Views.MainWindow" { DialogHost { DockPanel { - IsEnabled: bind IsBusy - convert (bool b) => b ? false : true - // Toolbar Border { DockPanel.Dock: Top @@ -101,6 +98,8 @@ 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