summaryrefslogtreecommitdiff
path: root/components
diff options
context:
space:
mode:
authorouwou <26526779+ouwou@users.noreply.github.com>2020-08-19 02:05:26 -0400
committerouwou <26526779+ouwou@users.noreply.github.com>2020-08-19 02:05:26 -0400
commit0cd0260f2e4cfe11678cdac4f965c9abf64b3592 (patch)
tree505443c34c3a73b26863bdeca890eae8916d05a8 /components
parent69404a97cdf759dcf56bc5b81ef0278080f64156 (diff)
downloadabaddon-portaudio-0cd0260f2e4cfe11678cdac4f965c9abf64b3592.tar.gz
abaddon-portaudio-0cd0260f2e4cfe11678cdac4f965c9abf64b3592.zip
disconnecting clears the channel listing
Diffstat (limited to 'components')
-rw-r--r--components/channels.cpp12
-rw-r--r--components/channels.hpp1
2 files changed, 13 insertions, 0 deletions
diff --git a/components/channels.cpp b/components/channels.cpp
index 10a9452..e26618c 100644
--- a/components/channels.cpp
+++ b/components/channels.cpp
@@ -31,6 +31,12 @@ void ChannelList::SetListingFromGuilds(const DiscordClient::Guilds_t &guilds) {
m_update_dispatcher.emit();
}
+void ChannelList::ClearListing() {
+ std::scoped_lock<std::mutex> guard(m_update_mutex);
+ m_update_queue.push(DiscordClient::Guilds_t());
+ m_update_dispatcher.emit();
+}
+
void ChannelList::on_row_activated(Gtk::ListBoxRow *row) {
auto &info = m_infos[row];
bool new_collapsed = !info.IsUserCollapsed;
@@ -77,6 +83,12 @@ void ChannelList::SetListingFromGuildsInternal() {
it++;
}
+ if (guilds->empty()) {
+ std::scoped_lock<std::mutex> guard(m_update_mutex);
+ m_update_queue.pop();
+ return;
+ }
+
auto &settings = m_abaddon->GetDiscordClient().GetUserSettings();
std::vector<std::pair<Snowflake, GuildData>> sorted_guilds;
diff --git a/components/channels.hpp b/components/channels.hpp
index a4ad583..d15846d 100644
--- a/components/channels.hpp
+++ b/components/channels.hpp
@@ -12,6 +12,7 @@ public:
ChannelList();
Gtk::Widget *GetRoot() const;
void SetListingFromGuilds(const DiscordClient::Guilds_t &guilds);
+ void ClearListing();
void SetAbaddon(Abaddon *ptr);