only load 50 messages on channel switch (also fix member menu)

This commit is contained in:
ouwou
2020-09-14 00:17:58 -04:00
parent 2822add5fe
commit e5a90b9461
8 changed files with 46 additions and 2 deletions

View File

@@ -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;
}