summaryrefslogtreecommitdiff
path: root/src/components/chatlist.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/components/chatlist.cpp')
-rw-r--r--src/components/chatlist.cpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/components/chatlist.cpp b/src/components/chatlist.cpp
index 93fb46f..28981b2 100644
--- a/src/components/chatlist.cpp
+++ b/src/components/chatlist.cpp
@@ -253,6 +253,23 @@ void ChatList::ActuallyRemoveMessage(Snowflake id) {
RemoveMessageAndHeader(it->second);
}
+std::optional<Snowflake> ChatList::GetLastSentMessage() {
+ const auto &discord = Abaddon::Get().GetDiscordClient();
+ const auto self_id = discord.GetUserData().ID;
+
+ std::map<Snowflake, Gtk::Widget *> ordered(m_id_to_widget.begin(), m_id_to_widget.end());
+
+ for (auto it = ordered.crbegin(); it != ordered.crend(); it++) {
+ const auto *widget = dynamic_cast<ChatMessageItemContainer*>(it->second);
+ if (widget == nullptr) continue;
+ const auto msg = discord.GetMessage(widget->ID);
+ if (!msg.has_value()) continue;
+ if (msg->Author.ID == self_id) return msg->ID;
+ }
+
+ return std::nullopt;
+}
+
void ChatList::SetupMenu() {
m_menu_copy_id = Gtk::manage(new Gtk::MenuItem("Copy ID"));
m_menu_copy_id->signal_activate().connect([this] {