summaryrefslogtreecommitdiff
path: root/components/memberlist.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'components/memberlist.cpp')
-rw-r--r--components/memberlist.cpp19
1 files changed, 17 insertions, 2 deletions
diff --git a/components/memberlist.cpp b/components/memberlist.cpp
index 61f5791..36bce1f 100644
--- a/components/memberlist.cpp
+++ b/components/memberlist.cpp
@@ -29,10 +29,19 @@ Gtk::Widget *MemberList::GetRoot() const {
return m_main;
}
+void MemberList::Clear() {
+ SetActiveChannel(Snowflake::Invalid);
+ UpdateMemberList();
+}
+
void MemberList::SetActiveChannel(Snowflake id) {
std::scoped_lock<std::mutex> guard(m_mutex);
m_chan_id = id;
- m_guild_id = Abaddon::Get().GetDiscordClient().GetChannel(id)->GuildID;
+ m_guild_id = Snowflake::Invalid;
+ if (m_chan_id.IsValid()) {
+ auto *chan = Abaddon::Get().GetDiscordClient().GetChannel(id);
+ if (chan != nullptr) m_guild_id = chan->GuildID;
+ }
}
void MemberList::UpdateMemberList() {
@@ -48,10 +57,12 @@ void MemberList::UpdateMemberListInternal() {
it++;
}
+ if (!Abaddon::Get().GetDiscordClient().IsStarted()) return;
if (!m_chan_id.IsValid()) return;
auto &discord = Abaddon::Get().GetDiscordClient();
auto *chan = discord.GetChannel(m_chan_id);
+ if (chan == nullptr) return;
std::unordered_set<Snowflake> ids;
if (chan->Type == ChannelType::DM || chan->Type == ChannelType::GROUP_DM) {
for (const auto &user : chan->Recipients)
@@ -165,7 +176,7 @@ void MemberList::on_copy_id_activate() {
void MemberList::on_insert_mention_activate() {
auto *row = dynamic_cast<MemberListUserRow *>(m_row_menu_target);
if (row == nullptr) return;
- Abaddon::Get().ActionInsertMention(row->ID);
+ m_signal_action_insert_mention.emit(row->ID);
}
void MemberList::AttachUserMenuHandler(Gtk::ListBoxRow *row, Snowflake id) {
@@ -179,3 +190,7 @@ void MemberList::AttachUserMenuHandler(Gtk::ListBoxRow *row, Snowflake id) {
return false;
});
}
+
+MemberList::type_signal_action_insert_mention MemberList::signal_action_insert_mention() {
+ return m_signal_action_insert_mention;
+}