diff options
author | ouwou <26526779+ouwou@users.noreply.github.com> | 2021-04-12 02:21:26 -0400 |
---|---|---|
committer | ouwou <26526779+ouwou@users.noreply.github.com> | 2021-04-12 02:21:26 -0400 |
commit | bf9b053d365344476b13e837f0b9da28cf8220f9 (patch) | |
tree | 6fa155c78f425fb37fc0cb26fe3a3a07abe34bd5 /components | |
parent | 244726fc66c98215b2ec7d0ee43e668f431d5861 (diff) | |
download | abaddon-portaudio-bf9b053d365344476b13e837f0b9da28cf8220f9.tar.gz abaddon-portaudio-bf9b053d365344476b13e837f0b9da28cf8220f9.zip |
split messages from the same author after 10 mins
Diffstat (limited to 'components')
-rw-r--r-- | components/chatmessage.cpp | 4 | ||||
-rw-r--r-- | components/chatmessage.hpp | 1 | ||||
-rw-r--r-- | components/chatwindow.cpp | 4 |
3 files changed, 8 insertions, 1 deletions
diff --git a/components/chatmessage.cpp b/components/chatmessage.cpp index 8608fdc..97d6d4a 100644 --- a/components/chatmessage.cpp +++ b/components/chatmessage.cpp @@ -1210,4 +1210,8 @@ void ChatMessageHeader::AddContent(Gtk::Widget *widget, bool prepend) { m_content_box->add(*widget); if (prepend) m_content_box->reorder_child(*widget, 1); + if (auto *x = dynamic_cast<ChatMessageItemContainer *>(widget)) { + if (x->ID > NewestID) + NewestID = x->ID; + } } diff --git a/components/chatmessage.hpp b/components/chatmessage.hpp index 1e92882..6074b20 100644 --- a/components/chatmessage.hpp +++ b/components/chatmessage.hpp @@ -109,6 +109,7 @@ class ChatMessageHeader : public Gtk::ListBoxRow { public: Snowflake UserID; Snowflake ChannelID; + Snowflake NewestID = 0; ChatMessageHeader(const Message *data); void AddContent(Gtk::Widget *widget, bool prepend); diff --git a/components/chatwindow.cpp b/components/chatwindow.cpp index 28c9820..8235a21 100644 --- a/components/chatwindow.cpp +++ b/components/chatwindow.cpp @@ -4,6 +4,8 @@ #include "chatinputindicator.hpp" #include "chatinput.hpp" +constexpr static uint64_t SnowflakeSplitDifference = 600; + ChatWindow::ChatWindow() { Abaddon::Get().GetDiscordClient().signal_message_send_fail().connect(sigc::mem_fun(*this, &ChatWindow::OnMessageSendFail)); @@ -238,7 +240,7 @@ void ChatWindow::ProcessNewMessage(Snowflake id, bool prepend) { last_row = dynamic_cast<ChatMessageHeader *>(m_list->get_row_at_index(m_num_rows - 1)); if (last_row != nullptr) - if (last_row->UserID == data->Author.ID) + if (last_row->UserID == data->Author.ID && (prepend || (id - last_row->NewestID < SnowflakeSplitDifference * Snowflake::SecondsInterval))) should_attach = true; } |