mirror of
https://github.com/Tyrrrz/DiscordChatExporter.git
synced 2026-04-29 01:07:47 +00:00
Don't disable everything when busy
This commit is contained in:
@@ -21,10 +21,10 @@ namespace DiscordChatExporter.ViewModels
|
|||||||
private readonly Dictionary<Guild, IReadOnlyList<Channel>> _guildChannelsMap;
|
private readonly Dictionary<Guild, IReadOnlyList<Channel>> _guildChannelsMap;
|
||||||
|
|
||||||
private bool _isBusy;
|
private bool _isBusy;
|
||||||
|
|
||||||
private IReadOnlyList<Guild> _availableGuilds;
|
private IReadOnlyList<Guild> _availableGuilds;
|
||||||
private Guild _selectedGuild;
|
private Guild _selectedGuild;
|
||||||
private IReadOnlyList<Channel> _availableChannels;
|
private IReadOnlyList<Channel> _availableChannels;
|
||||||
|
private string _cachedToken;
|
||||||
|
|
||||||
public bool IsBusy
|
public bool IsBusy
|
||||||
{
|
{
|
||||||
@@ -102,26 +102,24 @@ namespace DiscordChatExporter.ViewModels
|
|||||||
private async void PullData()
|
private async void PullData()
|
||||||
{
|
{
|
||||||
IsBusy = true;
|
IsBusy = true;
|
||||||
|
_cachedToken = Token;
|
||||||
|
|
||||||
// Clear existing
|
// Clear existing
|
||||||
_guildChannelsMap.Clear();
|
_guildChannelsMap.Clear();
|
||||||
AvailableGuilds = new Guild[0];
|
|
||||||
AvailableChannels = new Channel[0];
|
|
||||||
SelectedGuild = null;
|
|
||||||
|
|
||||||
// Get DM channels
|
// Get DM channels
|
||||||
{
|
{
|
||||||
var channels = await _dataService.GetDirectMessageChannelsAsync(Token);
|
var channels = await _dataService.GetDirectMessageChannelsAsync(_cachedToken);
|
||||||
var guild = new Guild("@me", "Direct Messages", null);
|
var guild = new Guild("@me", "Direct Messages", null);
|
||||||
_guildChannelsMap[guild] = channels.ToArray();
|
_guildChannelsMap[guild] = channels.ToArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get guild channels
|
// Get guild channels
|
||||||
{
|
{
|
||||||
var guilds = await _dataService.GetGuildsAsync(Token);
|
var guilds = await _dataService.GetGuildsAsync(_cachedToken);
|
||||||
foreach (var guild in guilds)
|
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);
|
channels = channels.Where(c => c.Type == ChannelType.GuildTextChat);
|
||||||
_guildChannelsMap[guild] = channels.ToArray();
|
_guildChannelsMap[guild] = channels.ToArray();
|
||||||
}
|
}
|
||||||
@@ -155,7 +153,7 @@ namespace DiscordChatExporter.ViewModels
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Get messages
|
// Get messages
|
||||||
var messages = await _dataService.GetChannelMessagesAsync(Token, channel.Id);
|
var messages = await _dataService.GetChannelMessagesAsync(_cachedToken, channel.Id);
|
||||||
|
|
||||||
// Create log
|
// Create log
|
||||||
var chatLog = new ChannelChatLog(SelectedGuild, channel, messages);
|
var chatLog = new ChannelChatLog(SelectedGuild, channel, messages);
|
||||||
|
|||||||
@@ -20,9 +20,6 @@ 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
|
||||||
@@ -101,6 +98,8 @@ 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
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user