diff options
author | ouwou <26526779+ouwou@users.noreply.github.com> | 2020-09-14 00:17:58 -0400 |
---|---|---|
committer | ouwou <26526779+ouwou@users.noreply.github.com> | 2020-09-14 00:17:58 -0400 |
commit | e5a90b94618bafc6bc99afbbff37f7aa3d6a97cf (patch) | |
tree | 28e9dd46f0a423252133ff3b21e508f37e348d55 /windows | |
parent | 2822add5fe791a120c160e188cecac7ce29d9961 (diff) | |
download | abaddon-portaudio-e5a90b94618bafc6bc99afbbff37f7aa3d6a97cf.tar.gz abaddon-portaudio-e5a90b94618bafc6bc99afbbff37f7aa3d6a97cf.zip |
only load 50 messages on channel switch (also fix member menu)
Diffstat (limited to 'windows')
-rw-r--r-- | windows/mainwindow.cpp | 16 | ||||
-rw-r--r-- | windows/mainwindow.hpp | 1 |
2 files changed, 16 insertions, 1 deletions
diff --git a/windows/mainwindow.cpp b/windows/mainwindow.cpp index 30d52bb..d4453af 100644 --- a/windows/mainwindow.cpp +++ b/windows/mainwindow.cpp @@ -111,7 +111,17 @@ void MainWindow::UpdateChannelListing() { void MainWindow::UpdateChatWindowContents() { auto &discord = Abaddon::Get().GetDiscordClient(); - m_chat.SetMessages(discord.GetMessagesForChannel(m_chat.GetActiveChannel())); + auto allmsgs = discord.GetMessagesForChannel(m_chat.GetActiveChannel()); + if (allmsgs.size() > 50) { + std::vector<Snowflake> msgvec(allmsgs.begin(), allmsgs.end()); + std::vector<Snowflake> cutvec(msgvec.end() - 50, msgvec.end()); + std::set<Snowflake> msgs; + for (const auto s : cutvec) + msgs.insert(s); + m_chat.SetMessages(msgs); + } else { + m_chat.SetMessages(allmsgs); + } m_members.UpdateMemberList(); } @@ -151,6 +161,10 @@ void MainWindow::InsertChatInput(std::string text) { m_chat.InsertChatInput(text); } +Snowflake MainWindow::GetChatOldestListedMessage() { + return m_chat.GetOldestListedMessage(); +} + ChannelList *MainWindow::GetChannelList() { return &m_channel_list; } diff --git a/windows/mainwindow.hpp b/windows/mainwindow.hpp index e850fa2..7480346 100644 --- a/windows/mainwindow.hpp +++ b/windows/mainwindow.hpp @@ -19,6 +19,7 @@ public: void UpdateChatMessageEditContent(Snowflake id, Snowflake channel_id); void UpdateChatPrependHistory(const std::vector<Snowflake> &msgs); void InsertChatInput(std::string text); + Snowflake GetChatOldestListedMessage(); ChannelList *GetChannelList(); ChatWindow *GetChatWindow(); |