mirror of
https://github.com/celisej567/abaddon.git
synced 2026-09-06 20:15:19 +03:00
friends: handle RELATIONSHIP_ADD events
This commit is contained in:
@@ -7,6 +7,7 @@ FriendsList::FriendsList()
|
||||
, m_filter_mode(FILTER_FRIENDS) {
|
||||
auto &discord = Abaddon::Get().GetDiscordClient();
|
||||
|
||||
discord.signal_relationship_add().connect(sigc::mem_fun(*this, &FriendsList::OnRelationshipAdd));
|
||||
discord.signal_relationship_remove().connect(sigc::mem_fun(*this, &FriendsList::OnRelationshipRemove));
|
||||
|
||||
for (const auto &[id, type] : discord.GetRelationships()) {
|
||||
@@ -71,6 +72,19 @@ FriendsList::FriendsList()
|
||||
m_list.show();
|
||||
}
|
||||
|
||||
void FriendsList::OnRelationshipAdd(const RelationshipAddData &data) {
|
||||
for (auto *row_ : m_list.get_children()) {
|
||||
auto *row = dynamic_cast<FriendsListFriendRow *>(row_);
|
||||
if (row == nullptr || row->ID != data.ID) continue;
|
||||
delete row;
|
||||
break;
|
||||
}
|
||||
|
||||
auto *row = Gtk::manage(new FriendsListFriendRow(data.Type, data.User));
|
||||
m_list.add(*row);
|
||||
row->show();
|
||||
}
|
||||
|
||||
void FriendsList::OnRelationshipRemove(Snowflake id, RelationshipType type) {
|
||||
for (auto *row_ : m_list.get_children()) {
|
||||
auto *row = dynamic_cast<FriendsListFriendRow *>(row_);
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
#pragma once
|
||||
#include <gtkmm.h>
|
||||
#include "../discord/relationship.hpp"
|
||||
#include "../discord/activity.hpp"
|
||||
#include "../discord/objects.hpp"
|
||||
|
||||
class FriendsListAddComponent : public Gtk::Box {
|
||||
public:
|
||||
@@ -20,6 +19,7 @@ public:
|
||||
FriendsList();
|
||||
|
||||
private:
|
||||
void OnRelationshipAdd(const RelationshipAddData &data);
|
||||
void OnRelationshipRemove(Snowflake id, RelationshipType type);
|
||||
|
||||
enum FilterMode {
|
||||
|
||||
Reference in New Issue
Block a user