summaryrefslogtreecommitdiff
path: root/components
diff options
context:
space:
mode:
authorouwou <26526779+ouwou@users.noreply.github.com>2021-08-02 02:00:03 -0400
committerouwou <26526779+ouwou@users.noreply.github.com>2021-08-02 02:00:03 -0400
commita19d21427206bcd5ab5cc0af273a05f3fe827720 (patch)
tree5cf31225cbe83450cd07619d546048a9ffeff5ca /components
parent06f85c3a2de5af9e0d63ff86a8e411030d1ee45d (diff)
downloadabaddon-portaudio-a19d21427206bcd5ab5cc0af273a05f3fe827720.tar.gz
abaddon-portaudio-a19d21427206bcd5ab5cc0af273a05f3fe827720.zip
basic THREAD_MEMBERS_UPDATE handling for updating channel list
Diffstat (limited to 'components')
-rw-r--r--components/channels.cpp18
-rw-r--r--components/channels.hpp5
2 files changed, 19 insertions, 4 deletions
diff --git a/components/channels.cpp b/components/channels.cpp
index ed5de62..644e090 100644
--- a/components/channels.cpp
+++ b/components/channels.cpp
@@ -142,7 +142,8 @@ ChannelList::ChannelList()
discord.signal_channel_update().connect(sigc::mem_fun(*this, &ChannelList::UpdateChannel));
discord.signal_channel_create().connect(sigc::mem_fun(*this, &ChannelList::UpdateCreateChannel));
discord.signal_thread_create().connect(sigc::mem_fun(*this, &ChannelList::UpdateCreateThread));
- discord.signal_thread_delete().connect(sigc::mem_fun(*this, &ChannelList::UpdateDeleteThread));
+ discord.signal_thread_delete().connect(sigc::mem_fun(*this, &ChannelList::OnThreadDelete));
+ discord.signal_thread_members_update().connect(sigc::mem_fun(*this, &ChannelList::OnThreadMembersUpdate));
discord.signal_guild_update().connect(sigc::mem_fun(*this, &ChannelList::UpdateGuild));
}
@@ -279,14 +280,25 @@ void ChannelList::UpdateGuild(Snowflake id) {
}
}
+void ChannelList::OnThreadDelete(const ThreadDeleteData &data) {
+ UpdateDeleteThread(data.ID);
+}
+
+void ChannelList::OnThreadMembersUpdate(const ThreadMembersUpdateData &data) {
+ auto &r = data.RemovedMemberIDs;
+ if (r.has_value() && std::find(r->begin(), r->end(), Abaddon::Get().GetDiscordClient().GetUserData().ID) != r->end()) {
+ UpdateDeleteThread(data.ID);
+ }
+}
+
void ChannelList::UpdateCreateThread(const ChannelData &channel) {
auto parent_row = GetIteratorForChannelFromID(*channel.ParentID);
if (parent_row)
CreateThreadRow(parent_row->children(), channel);
}
-void ChannelList::UpdateDeleteThread(const ThreadDeleteData &data) {
- auto iter = GetIteratorForChannelFromID(data.ID);
+void ChannelList::UpdateDeleteThread(Snowflake id) {
+ auto iter = GetIteratorForChannelFromID(id);
if (iter)
m_model->erase(iter);
}
diff --git a/components/channels.hpp b/components/channels.hpp
index c131a07..24c7170 100644
--- a/components/channels.hpp
+++ b/components/channels.hpp
@@ -141,9 +141,12 @@ protected:
void UpdateChannel(Snowflake id);
void UpdateCreateChannel(const ChannelData &channel);
void UpdateCreateThread(const ChannelData &channel);
- void UpdateDeleteThread(const ThreadDeleteData &data);
+ void UpdateDeleteThread(Snowflake id);
void UpdateGuild(Snowflake id);
+ void OnThreadDelete(const ThreadDeleteData &data);
+ void OnThreadMembersUpdate(const ThreadMembersUpdateData &data);
+
Gtk::TreeView m_view;
class ModelColumns : public Gtk::TreeModel::ColumnRecord {