summaryrefslogtreecommitdiff
path: root/abaddon.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'abaddon.cpp')
-rw-r--r--abaddon.cpp29
1 files changed, 27 insertions, 2 deletions
diff --git a/abaddon.cpp b/abaddon.cpp
index 04d80ac..48ba1fd 100644
--- a/abaddon.cpp
+++ b/abaddon.cpp
@@ -121,7 +121,7 @@ void Abaddon::ActionMoveGuildUp(Snowflake id) {
std::swap(*left, *target_iter);
std::vector<Snowflake> new_sort;
- for (const auto& x : order)
+ for (const auto &x : order)
new_sort.push_back(x.first);
m_discord.UpdateSettingsGuildPositions(new_sort);
@@ -156,14 +156,39 @@ void Abaddon::ActionListChannelItemClick(Snowflake id) {
m_main_window->UpdateChatActiveChannel(id);
if (m_channels_requested.find(id) == m_channels_requested.end()) {
m_discord.FetchMessagesInChannel(id, [this, id](const std::vector<MessageData> &msgs) {
+ if (msgs.size() > 0) {
+ m_oldest_listed_message[id] = msgs.back().ID;
+ m_main_window->UpdateChatWindowContents();
+ }
+
m_channels_requested.insert(id);
- m_main_window->UpdateChatWindowContents();
});
} else {
m_main_window->UpdateChatWindowContents();
}
}
+void Abaddon::ActionChatLoadHistory(Snowflake id) {
+ if (m_channels_history_loaded.find(id) != m_channels_history_loaded.end())
+ return;
+
+ if (m_channels_history_loading.find(id) != m_channels_history_loading.end())
+ return;
+
+ m_channels_history_loading.insert(id);
+
+ m_discord.FetchMessagesInChannelBefore(id, m_oldest_listed_message[id], [this, id](const std::vector<MessageData> &msgs) {
+ m_channels_history_loading.erase(id);
+
+ if (msgs.size() == 0) {
+ m_channels_history_loaded.insert(id);
+ } else {
+ m_oldest_listed_message[id] = msgs.back().ID;
+ m_main_window->UpdateChatPrependHistory(msgs);
+ }
+ });
+}
+
void Abaddon::ActionChatInputSubmit(std::string msg, Snowflake channel) {
m_discord.SendChatMessage(msg, channel);
}