diff options
author | ouwou <26526779+ouwou@users.noreply.github.com> | 2021-05-08 23:49:27 -0400 |
---|---|---|
committer | ouwou <26526779+ouwou@users.noreply.github.com> | 2021-05-08 23:49:27 -0400 |
commit | a781cc76a01d56244fd6caeb23ab67caf2424819 (patch) | |
tree | 96aa8ed6ff5b31fced3a017d9cc36c61ecc6cecb /components | |
parent | abd2b9c71e98f3d9feab8d5b4d288b246015ee0d (diff) | |
download | abaddon-portaudio-a781cc76a01d56244fd6caeb23ab67caf2424819.tar.gz abaddon-portaudio-a781cc76a01d56244fd6caeb23ab67caf2424819.zip |
friends: handle RELATIONSHIP_REMOVE events
Diffstat (limited to 'components')
-rw-r--r-- | components/friendslist.cpp | 11 | ||||
-rw-r--r-- | components/friendslist.hpp | 2 |
2 files changed, 13 insertions, 0 deletions
diff --git a/components/friendslist.cpp b/components/friendslist.cpp index 704d278..2221547 100644 --- a/components/friendslist.cpp +++ b/components/friendslist.cpp @@ -7,6 +7,8 @@ FriendsList::FriendsList() , m_filter_mode(FILTER_FRIENDS) { auto &discord = Abaddon::Get().GetDiscordClient(); + discord.signal_relationship_remove().connect(sigc::mem_fun(*this, &FriendsList::OnRelationshipRemove)); + for (const auto &[id, type] : discord.GetRelationships()) { const auto user = discord.GetUser(id); if (!user.has_value()) continue; @@ -69,6 +71,15 @@ FriendsList::FriendsList() m_list.show(); } +void FriendsList::OnRelationshipRemove(Snowflake id, RelationshipType type) { + for (auto *row_ : m_list.get_children()) { + auto *row = dynamic_cast<FriendsListFriendRow *>(row_); + if (row == nullptr || row->ID != id) continue; + delete row; + return; + } +} + int FriendsList::ListSortFunc(Gtk::ListBoxRow *a_, Gtk::ListBoxRow *b_) { auto *a = dynamic_cast<FriendsListFriendRow *>(a_); auto *b = dynamic_cast<FriendsListFriendRow *>(b_); diff --git a/components/friendslist.hpp b/components/friendslist.hpp index fef04da..c161de4 100644 --- a/components/friendslist.hpp +++ b/components/friendslist.hpp @@ -20,6 +20,8 @@ public: FriendsList(); private: + void OnRelationshipRemove(Snowflake id, RelationshipType type); + enum FilterMode { FILTER_FRIENDS, FILTER_ONLINE, |