mirror of
https://github.com/celisej567/abaddon.git
synced 2026-09-06 20:15:19 +03:00
friends: handle RELATIONSHIP_REMOVE events
This commit is contained in:
@@ -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_);
|
||||
|
||||
@@ -20,6 +20,8 @@ public:
|
||||
FriendsList();
|
||||
|
||||
private:
|
||||
void OnRelationshipRemove(Snowflake id, RelationshipType type);
|
||||
|
||||
enum FilterMode {
|
||||
FILTER_FRIENDS,
|
||||
FILTER_ONLINE,
|
||||
|
||||
Reference in New Issue
Block a user