From 00524cefa29e80f0a9a80fd77bb6e1f4da024f65 Mon Sep 17 00:00:00 2001 From: ouwou <26526779+ouwou@users.noreply.github.com> Date: Sat, 15 Jul 2023 01:02:35 -0400 Subject: make editing inline, add up arrow shortcut --- src/components/chatlist.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'src/components/chatlist.cpp') 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 ChatList::GetLastSentMessage() { + const auto &discord = Abaddon::Get().GetDiscordClient(); + const auto self_id = discord.GetUserData().ID; + + std::map 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(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] { -- cgit v1.2.3