forked from OpenGamers/abaddon
pins: separate msgs, sort and store
This commit is contained in:
@@ -61,7 +61,7 @@ void ChatList::ProcessNewMessage(const Message &data, bool prepend) {
|
|||||||
|
|
||||||
ChatMessageHeader *last_row = nullptr;
|
ChatMessageHeader *last_row = nullptr;
|
||||||
bool should_attach = false;
|
bool should_attach = false;
|
||||||
if (m_num_rows > 0) {
|
if (!m_separate_all && m_num_rows > 0) {
|
||||||
if (prepend)
|
if (prepend)
|
||||||
last_row = dynamic_cast<ChatMessageHeader *>(m_list.get_row_at_index(0));
|
last_row = dynamic_cast<ChatMessageHeader *>(m_list.get_row_at_index(0));
|
||||||
else
|
else
|
||||||
@@ -210,6 +210,10 @@ std::vector<Snowflake> ChatList::GetRecentAuthors() {
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ChatList::SetSeparateAll(bool separate) {
|
||||||
|
m_separate_all = true;
|
||||||
|
}
|
||||||
|
|
||||||
void ChatList::OnScrollEdgeOvershot(Gtk::PositionType pos) {
|
void ChatList::OnScrollEdgeOvershot(Gtk::PositionType pos) {
|
||||||
if (pos == Gtk::POS_TOP)
|
if (pos == Gtk::POS_TOP)
|
||||||
m_signal_action_chat_load_history.emit(m_active_channel);
|
m_signal_action_chat_load_history.emit(m_active_channel);
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ public:
|
|||||||
void UpdateMessageReactions(Snowflake id);
|
void UpdateMessageReactions(Snowflake id);
|
||||||
void SetFailedByNonce(const std::string &nonce);
|
void SetFailedByNonce(const std::string &nonce);
|
||||||
std::vector<Snowflake> GetRecentAuthors();
|
std::vector<Snowflake> GetRecentAuthors();
|
||||||
|
void SetSeparateAll(bool separate);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void OnScrollEdgeOvershot(Gtk::PositionType pos);
|
void OnScrollEdgeOvershot(Gtk::PositionType pos);
|
||||||
@@ -35,6 +36,8 @@ private:
|
|||||||
bool m_should_scroll_to_bottom = true;
|
bool m_should_scroll_to_bottom = true;
|
||||||
Gtk::ListBox m_list;
|
Gtk::ListBox m_list;
|
||||||
|
|
||||||
|
bool m_separate_all = false;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// these are all forwarded by the parent
|
// these are all forwarded by the parent
|
||||||
using type_signal_action_message_delete = sigc::signal<void, Snowflake, Snowflake>;
|
using type_signal_action_message_delete = sigc::signal<void, Snowflake, Snowflake>;
|
||||||
|
|||||||
@@ -718,6 +718,9 @@ void DiscordClient::FetchPinned(Snowflake id, sigc::slot<void(std::vector<Messag
|
|||||||
}
|
}
|
||||||
|
|
||||||
auto data = nlohmann::json::parse(response.text).get<std::vector<Message>>();
|
auto data = nlohmann::json::parse(response.text).get<std::vector<Message>>();
|
||||||
|
std::sort(data.begin(), data.end(), [](const Message &a, const Message &b) { return a.ID < b.ID; });
|
||||||
|
for (auto &msg : data)
|
||||||
|
StoreMessageData(msg);
|
||||||
callback(std::move(data), DiscordError::NONE);
|
callback(std::move(data), DiscordError::NONE);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ PinnedWindow::PinnedWindow(const ChannelData &data)
|
|||||||
add(m_chat);
|
add(m_chat);
|
||||||
m_chat.show();
|
m_chat.show();
|
||||||
|
|
||||||
|
m_chat.SetSeparateAll(true);
|
||||||
m_chat.SetActiveChannel(ChannelID);
|
m_chat.SetActiveChannel(ChannelID);
|
||||||
|
|
||||||
FetchPinned();
|
FetchPinned();
|
||||||
|
|||||||
Reference in New Issue
Block a user