diff options
author | ouwou <26526779+ouwou@users.noreply.github.com> | 2020-09-09 23:59:40 -0400 |
---|---|---|
committer | ouwou <26526779+ouwou@users.noreply.github.com> | 2020-09-09 23:59:40 -0400 |
commit | 6ae9cc915d8bba9415910f4c9745e1158a7e1f68 (patch) | |
tree | 0ebce2462d4358be0f322e05726cf4a2de666293 | |
parent | 51cf8fd2df3cf7a602d05540627a5ad8af6baa58 (diff) | |
download | abaddon-portaudio-6ae9cc915d8bba9415910f4c9745e1158a7e1f68.tar.gz abaddon-portaudio-6ae9cc915d8bba9415910f4c9745e1158a7e1f68.zip |
MessageData -> Message (whoops)
-rw-r--r-- | components/chatmessage.cpp | 6 | ||||
-rw-r--r-- | components/chatmessage.hpp | 7 | ||||
-rw-r--r-- | components/chatwindow.cpp | 6 | ||||
-rw-r--r-- | components/chatwindow.hpp | 4 | ||||
-rw-r--r-- | discord/discord.cpp | 10 | ||||
-rw-r--r-- | discord/discord.hpp | 2 | ||||
-rw-r--r-- | discord/message.cpp | 4 | ||||
-rw-r--r-- | discord/message.hpp | 4 | ||||
-rw-r--r-- | discord/store.cpp | 4 | ||||
-rw-r--r-- | discord/store.hpp | 6 |
10 files changed, 27 insertions, 26 deletions
diff --git a/components/chatmessage.cpp b/components/chatmessage.cpp index e89f43a..57a1f99 100644 --- a/components/chatmessage.cpp +++ b/components/chatmessage.cpp @@ -4,7 +4,7 @@ #include "../abaddon.hpp" #include "../util.hpp" -ChatMessageContainer::ChatMessageContainer(const MessageData *data) { +ChatMessageContainer::ChatMessageContainer(const Message *data) { UserID = data->Author.ID; ChannelID = data->ChannelID; @@ -141,7 +141,7 @@ void ChatMessageItem::AddMenuItem(Gtk::MenuItem *item) { m_menu.append(*item); } -ChatMessageTextItem::ChatMessageTextItem(const MessageData *data) { +ChatMessageTextItem::ChatMessageTextItem(const Message *data) { m_content = data->Content; get_style_context()->add_class("message-text"); @@ -196,7 +196,7 @@ void ChatMessageTextItem::UpdateAttributes() { } } -ChatMessageEmbedItem::ChatMessageEmbedItem(const MessageData *data) { +ChatMessageEmbedItem::ChatMessageEmbedItem(const Message *data) { m_embed = data->Embeds[0]; DoLayout(); diff --git a/components/chatmessage.hpp b/components/chatmessage.hpp index 5620f60..d491322 100644 --- a/components/chatmessage.hpp +++ b/components/chatmessage.hpp @@ -8,6 +8,7 @@ enum class ChatDisplayType { Unknown, Text, Embed, + Image, }; // contains the username and timestamp, chat items get stuck into its box @@ -16,7 +17,7 @@ public: Snowflake UserID; Snowflake ChannelID; - ChatMessageContainer(const MessageData *data); + ChatMessageContainer(const Message *data); void AddNewContent(Gtk::Widget *widget, bool prepend = false); void Update(); @@ -68,7 +69,7 @@ class ChatMessageTextItem : public Gtk::TextView // oh well , public ChatMessageItem { public: - ChatMessageTextItem(const MessageData *data); + ChatMessageTextItem(const Message *data); void EditContent(std::string content); @@ -92,7 +93,7 @@ class ChatMessageEmbedItem : public Gtk::EventBox , public ChatMessageItem { public: - ChatMessageEmbedItem(const MessageData *data); + ChatMessageEmbedItem(const Message *data); virtual void MarkAsDeleted(); virtual void MarkAsEdited(); diff --git a/components/chatwindow.cpp b/components/chatwindow.cpp index 978704f..42e0a2c 100644 --- a/components/chatwindow.cpp +++ b/components/chatwindow.cpp @@ -82,7 +82,7 @@ Snowflake ChatWindow::GetActiveChannel() const { return m_active_channel; } -ChatDisplayType ChatWindow::GetMessageDisplayType(const MessageData *data) { +ChatDisplayType ChatWindow::GetMessageDisplayType(const Message *data) { if (data->Type == MessageType::DEFAULT && data->Content.size() > 0) return ChatDisplayType::Text; else if (data->Type == MessageType::DEFAULT && data->Embeds.size() > 0) @@ -91,7 +91,7 @@ ChatDisplayType ChatWindow::GetMessageDisplayType(const MessageData *data) { return ChatDisplayType::Unknown; } -void ChatWindow::ProcessMessage(const MessageData *data, bool prepend) { +void ChatWindow::ProcessMessage(const Message *data, bool prepend) { if (!Abaddon::Get().GetDiscordClient().IsStarted()) return; ChatMessageContainer *last_row = nullptr; @@ -307,7 +307,7 @@ void ChatWindow::SetMessagesInternal() { } // sort - std::map<Snowflake, const MessageData *> sorted_messages; + std::map<Snowflake, const Message *> sorted_messages; for (const auto id : *msgs) sorted_messages[id] = Abaddon::Get().GetDiscordClient().GetMessage(id); diff --git a/components/chatwindow.hpp b/components/chatwindow.hpp index c16216d..00d5e2b 100644 --- a/components/chatwindow.hpp +++ b/components/chatwindow.hpp @@ -29,8 +29,8 @@ protected: void AddNewHistoryInternal(); void DeleteMessageInternal(); void UpdateMessageContentInternal(); - ChatDisplayType GetMessageDisplayType(const MessageData *data); - void ProcessMessage(const MessageData *data, bool prepend = false); + ChatDisplayType GetMessageDisplayType(const Message *data); + void ProcessMessage(const Message *data, bool prepend = false); int m_num_rows = 0; // youd think thered be a Gtk::ListBox::get_row_count or something but nope std::unordered_map<Snowflake, ChatMessageItem *> m_id_to_widget; diff --git a/discord/discord.cpp b/discord/discord.cpp index 63722fe..470088b 100644 --- a/discord/discord.cpp +++ b/discord/discord.cpp @@ -115,7 +115,7 @@ void DiscordClient::FetchMessagesInChannel(Snowflake id, std::function<void(cons m_http.MakeGET(path, [this, id, cb](cpr::Response r) { if (!CheckCode(r)) return; - std::vector<MessageData> msgs; + std::vector<Message> msgs; std::vector<Snowflake> ids; nlohmann::json::parse(r.text).get_to(msgs); @@ -136,7 +136,7 @@ void DiscordClient::FetchMessagesInChannelBefore(Snowflake channel_id, Snowflake m_http.MakeGET(path, [this, channel_id, cb](cpr::Response r) { if (!CheckCode(r)) return; - std::vector<MessageData> msgs; + std::vector<Message> msgs; std::vector<Snowflake> ids; nlohmann::json::parse(r.text).get_to(msgs); @@ -152,7 +152,7 @@ void DiscordClient::FetchMessagesInChannelBefore(Snowflake channel_id, Snowflake }); } -const MessageData *DiscordClient::GetMessage(Snowflake id) const { +const Message *DiscordClient::GetMessage(Snowflake id) const { return m_store.GetMessage(id); } @@ -362,7 +362,7 @@ void DiscordClient::HandleGatewayReady(const GatewayMessage &msg) { } void DiscordClient::HandleGatewayMessageCreate(const GatewayMessage &msg) { - MessageData data = msg.Data; + Message data = msg.Data; m_store.SetMessage(data.ID, data); AddMessageToChannel(data.ID, data.ChannelID); m_store.SetUser(data.Author.ID, data.Author); @@ -377,7 +377,7 @@ void DiscordClient::HandleGatewayMessageDelete(const GatewayMessage &msg) { void DiscordClient::HandleGatewayMessageUpdate(const GatewayMessage &msg) { // less than stellar way of doing this probably - MessageData data; + Message data; data.from_json_edited(msg.Data); auto *current = m_store.GetMessage(data.ID); diff --git a/discord/discord.hpp b/discord/discord.hpp index f6e7241..a9d44dc 100644 --- a/discord/discord.hpp +++ b/discord/discord.hpp @@ -70,7 +70,7 @@ public: void UpdateSettingsGuildPositions(const std::vector<Snowflake> &pos); void FetchMessagesInChannel(Snowflake id, std::function<void(const std::vector<Snowflake> &)> cb); void FetchMessagesInChannelBefore(Snowflake channel_id, Snowflake before_id, std::function<void(const std::vector<Snowflake> &)> cb); - const MessageData *GetMessage(Snowflake id) const; + const Message *GetMessage(Snowflake id) const; const Channel *GetChannel(Snowflake id) const; const User *GetUser(Snowflake id) const; const Role *GetRole(Snowflake id) const; diff --git a/discord/message.cpp b/discord/message.cpp index 600ffcb..40c8d58 100644 --- a/discord/message.cpp +++ b/discord/message.cpp @@ -60,7 +60,7 @@ void from_json(const nlohmann::json &j, EmbedData &m) { JS_O("fields", m.Fields); } -void from_json(const nlohmann::json &j, MessageData &m) { +void from_json(const nlohmann::json &j, Message &m) { JS_D("id", m.ID); JS_D("channel_id", m.ChannelID); JS_O("guild_id", m.GuildID); @@ -88,7 +88,7 @@ void from_json(const nlohmann::json &j, MessageData &m) { } // probably gonna need to return present keys -void MessageData::from_json_edited(const nlohmann::json &j) { +void Message::from_json_edited(const nlohmann::json &j) { JS_D("id", ID); JS_D("channel_id", ChannelID); JS_O("guild_id", GuildID); diff --git a/discord/message.hpp b/discord/message.hpp index 7eb0cdc..e4f5b40 100644 --- a/discord/message.hpp +++ b/discord/message.hpp @@ -107,7 +107,7 @@ struct EmbedData { friend void from_json(const nlohmann::json &j, EmbedData &m); }; -struct MessageData { +struct Message { Snowflake ID; // Snowflake ChannelID; // Snowflake GuildID; // opt @@ -133,6 +133,6 @@ struct MessageData { // MessageReferenceData MessageReference; // opt MessageFlags Flags = MessageFlags::NONE; // opt - friend void from_json(const nlohmann::json &j, MessageData &m); + friend void from_json(const nlohmann::json &j, Message &m); void from_json_edited(const nlohmann::json &j); // for MESSAGE_UPDATE }; diff --git a/discord/store.cpp b/discord/store.cpp index badb46a..270f16c 100644 --- a/discord/store.cpp +++ b/discord/store.cpp @@ -16,7 +16,7 @@ void Store::SetRole(Snowflake id, const Role &role) { m_roles[id] = role; } -void Store::SetMessage(Snowflake id, const MessageData &message) { +void Store::SetMessage(Snowflake id, const Message &message) { m_messages[id] = message; } @@ -52,7 +52,7 @@ const Role *Store::GetRole(Snowflake id) const { return &it->second; } -const MessageData *Store::GetMessage(Snowflake id) const { +const Message *Store::GetMessage(Snowflake id) const { auto it = m_messages.find(id); if (it == m_messages.end()) return nullptr; diff --git a/discord/store.hpp b/discord/store.hpp index 124d126..398b725 100644 --- a/discord/store.hpp +++ b/discord/store.hpp @@ -13,21 +13,21 @@ public: void SetChannel(Snowflake id, const Channel &channel); void SetGuild(Snowflake id, const Guild &guild); void SetRole(Snowflake id, const Role &role); - void SetMessage(Snowflake id, const MessageData &message); + void SetMessage(Snowflake id, const Message &message); void SetGuildMemberData(Snowflake guild_id, Snowflake user_id, const GuildMember &data); const User *GetUser(Snowflake id) const; const Channel *GetChannel(Snowflake id) const; const Guild *GetGuild(Snowflake id) const; const Role *GetRole(Snowflake id) const; - const MessageData *GetMessage(Snowflake id) const; + const Message *GetMessage(Snowflake id) const; const GuildMember *GetGuildMemberData(Snowflake guild_id, Snowflake user_id) const; using users_type = std::unordered_map<Snowflake, User>; using channels_type = std::unordered_map<Snowflake, Channel>; using guilds_type = std::unordered_map<Snowflake, Guild>; using roles_type = std::unordered_map<Snowflake, Role>; - using messages_type = std::unordered_map<Snowflake, MessageData>; + using messages_type = std::unordered_map<Snowflake, Message>; using members_type = std::unordered_map<Snowflake, std::unordered_map<Snowflake, GuildMember>>; const channels_type &GetChannels() const; |