Don't disable everything when busy

pull/17/head
Alexey Golub 7 years ago
parent 151c5e2f23
commit c01b9d0e5f

@ -21,10 +21,10 @@ namespace DiscordChatExporter.ViewModels
private readonly Dictionary<Guild, IReadOnlyList<Channel>> _guildChannelsMap;
private bool _isBusy;
private IReadOnlyList<Guild> _availableGuilds;
private Guild _selectedGuild;
private IReadOnlyList<Channel> _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);

@ -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

Loading…
Cancel
Save