mirror of
https://github.com/celisej567/abaddon.git
synced 2026-09-06 20:15:19 +03:00
more reliable menu sensitivty/actions
This commit is contained in:
@@ -432,8 +432,7 @@ void Abaddon::ActionConnect() {
|
||||
}
|
||||
|
||||
void Abaddon::ActionDisconnect() {
|
||||
if (m_discord.IsStarted())
|
||||
StopDiscord();
|
||||
StopDiscord();
|
||||
}
|
||||
|
||||
void Abaddon::ActionSetToken() {
|
||||
|
||||
@@ -24,6 +24,8 @@ DiscordClient::DiscordClient(bool mem_store)
|
||||
}
|
||||
|
||||
void DiscordClient::Start() {
|
||||
if (m_client_started) return;
|
||||
|
||||
m_http.SetBase(GetAPIURL());
|
||||
|
||||
std::memset(&m_zstream, 0, sizeof(m_zstream));
|
||||
@@ -37,22 +39,22 @@ void DiscordClient::Start() {
|
||||
}
|
||||
|
||||
void DiscordClient::Stop() {
|
||||
if (m_client_started) {
|
||||
inflateEnd(&m_zstream);
|
||||
m_compressed_buf.clear();
|
||||
|
||||
m_heartbeat_waiter.kill();
|
||||
if (m_heartbeat_thread.joinable()) m_heartbeat_thread.join();
|
||||
m_client_connected = false;
|
||||
m_reconnecting = false;
|
||||
|
||||
m_store.ClearAll();
|
||||
m_guild_to_users.clear();
|
||||
|
||||
m_websocket.Stop();
|
||||
}
|
||||
|
||||
m_client_started = false;
|
||||
|
||||
if (!m_client_connected) return;
|
||||
|
||||
inflateEnd(&m_zstream);
|
||||
m_compressed_buf.clear();
|
||||
|
||||
m_heartbeat_waiter.kill();
|
||||
if (m_heartbeat_thread.joinable()) m_heartbeat_thread.join();
|
||||
m_client_connected = false;
|
||||
m_reconnecting = false;
|
||||
|
||||
m_store.ClearAll();
|
||||
m_guild_to_users.clear();
|
||||
|
||||
m_websocket.Stop();
|
||||
}
|
||||
|
||||
bool DiscordClient::IsStarted() const {
|
||||
|
||||
@@ -149,13 +149,6 @@ MainWindow::MainWindow()
|
||||
void MainWindow::UpdateComponents() {
|
||||
bool discord_active = Abaddon::Get().IsDiscordActive();
|
||||
|
||||
std::string token = Abaddon::Get().GetDiscordToken();
|
||||
m_menu_discord_connect.set_sensitive(token.size() > 0 && !discord_active);
|
||||
m_menu_discord_disconnect.set_sensitive(discord_active);
|
||||
m_menu_discord_join_guild.set_sensitive(discord_active);
|
||||
m_menu_discord_set_token.set_sensitive(!discord_active);
|
||||
m_menu_discord_set_status.set_sensitive(discord_active);
|
||||
|
||||
if (!discord_active) {
|
||||
m_chat.Clear();
|
||||
m_members.Clear();
|
||||
@@ -259,6 +252,15 @@ void MainWindow::OnDiscordSubmenuPopup(const Gdk::Rectangle *flipped_rect, const
|
||||
m_menu_discord_add_recipient.set_visible(false);
|
||||
if (channel.has_value() && channel->GetDMRecipients().size() + 1 < 10)
|
||||
m_menu_discord_add_recipient.set_visible(channel->Type == ChannelType::GROUP_DM);
|
||||
|
||||
const bool discord_active = Abaddon::Get().GetDiscordClient().IsStarted();
|
||||
|
||||
std::string token = Abaddon::Get().GetDiscordToken();
|
||||
m_menu_discord_connect.set_sensitive(token.size() > 0 && !discord_active);
|
||||
m_menu_discord_disconnect.set_sensitive(discord_active);
|
||||
m_menu_discord_join_guild.set_sensitive(discord_active);
|
||||
m_menu_discord_set_token.set_sensitive(!discord_active);
|
||||
m_menu_discord_set_status.set_sensitive(discord_active);
|
||||
}
|
||||
|
||||
void MainWindow::OnViewSubmenuPopup(const Gdk::Rectangle *flipped_rect, const Gdk::Rectangle *final_rect, bool flipped_x, bool flipped_y) {
|
||||
|
||||
Reference in New Issue
Block a user