From f69b0e61558680d9fdcaafd5c184b2c45fc06fce Mon Sep 17 00:00:00 2001 From: ouwou <26526779+ouwou@users.noreply.github.com> Date: Fri, 4 Sep 2020 00:48:38 -0400 Subject: pass around snowflake instead of MessageData --- components/chatwindow.cpp | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) (limited to 'components/chatwindow.cpp') diff --git a/components/chatwindow.cpp b/components/chatwindow.cpp index 2005554..2c0c4a0 100644 --- a/components/chatwindow.cpp +++ b/components/chatwindow.cpp @@ -166,7 +166,7 @@ void ChatWindow::on_scroll_edge_overshot(Gtk::PositionType pos) { m_abaddon->ActionChatLoadHistory(m_active_channel); } -void ChatWindow::SetMessages(std::unordered_set msgs) { +void ChatWindow::SetMessages(std::set msgs) { std::scoped_lock guard(m_update_mutex); m_message_set_queue.push(msgs); m_message_set_dispatch.emit(); @@ -178,12 +178,9 @@ void ChatWindow::AddNewMessage(Snowflake id) { m_new_message_dispatch.emit(); } -void ChatWindow::AddNewHistory(const std::vector &msgs) { +void ChatWindow::AddNewHistory(const std::vector &msgs) { std::scoped_lock guard(m_update_mutex); - std::vector x; - for (const auto &msg : msgs) - x.push_back(msg.ID); - m_new_history_queue.push(x); + m_new_history_queue.push(msgs); m_new_history_dispatch.emit(); } @@ -201,7 +198,7 @@ void ChatWindow::UpdateMessageContent(Snowflake id) { void ChatWindow::ClearMessages() { std::scoped_lock guard(m_update_mutex); - m_message_set_queue.push(std::unordered_set()); + m_message_set_queue.push(std::set()); m_message_set_dispatch.emit(); } @@ -289,7 +286,7 @@ void ChatWindow::SetMessagesInternal() { m_num_rows = 0; m_id_to_widget.clear(); - std::unordered_set *msgs; + std::set *msgs; { std::scoped_lock guard(m_update_mutex); msgs = &m_message_set_queue.front(); @@ -297,8 +294,8 @@ void ChatWindow::SetMessagesInternal() { // sort std::map sorted_messages; - for (const auto msg : *msgs) - sorted_messages[msg->ID] = msg; + for (const auto id : *msgs) + sorted_messages[id] = m_abaddon->GetDiscordClient().GetMessage(id); for (const auto &[id, msg] : sorted_messages) { ProcessMessage(msg); -- cgit v1.2.3