summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorouwou <26526779+ouwou@users.noreply.github.com>2021-05-08 23:37:52 -0400
committerouwou <26526779+ouwou@users.noreply.github.com>2021-05-08 23:37:52 -0400
commitabd2b9c71e98f3d9feab8d5b4d288b246015ee0d (patch)
treeaecc28fd04f15fd44cf88326739f140fb5421e48
parent78d3c5b679597dfa82910a6ea1e266349fa23a39 (diff)
parent469053a14468f08dc694a1ef8d98f0265a72dd07 (diff)
downloadabaddon-portaudio-abd2b9c71e98f3d9feab8d5b4d288b246015ee0d.tar.gz
abaddon-portaudio-abd2b9c71e98f3d9feab8d5b4d288b246015ee0d.zip
Merge branch 'master' into friends
-rw-r--r--components/chatmessage.cpp6
-rw-r--r--components/chatwindow.cpp3
-rw-r--r--discord/discord.cpp14
-rw-r--r--discord/discord.hpp4
-rw-r--r--discord/objects.cpp5
-rw-r--r--discord/objects.hpp8
6 files changed, 38 insertions, 2 deletions
diff --git a/components/chatmessage.cpp b/components/chatmessage.cpp
index 68d2359..5f95b47 100644
--- a/components/chatmessage.cpp
+++ b/components/chatmessage.cpp
@@ -143,8 +143,10 @@ void ChatMessageItemContainer::UpdateReactions() {
}
void ChatMessageItemContainer::SetFailed() {
- m_text_component->get_style_context()->remove_class("pending");
- m_text_component->get_style_context()->add_class("failed");
+ if (m_text_component != nullptr) {
+ m_text_component->get_style_context()->remove_class("pending");
+ m_text_component->get_style_context()->add_class("failed");
+ }
}
void ChatMessageItemContainer::UpdateAttributes() {
diff --git a/components/chatwindow.cpp b/components/chatwindow.cpp
index 1a2bb48..55ff06d 100644
--- a/components/chatwindow.cpp
+++ b/components/chatwindow.cpp
@@ -200,6 +200,9 @@ bool ChatWindow::OnInputSubmit(const Glib::ustring &text) {
if (!m_rate_limit_indicator->CanSpeak())
return false;
+ if (text.size() == 0)
+ return false;
+
if (m_active_channel.IsValid())
m_signal_action_chat_submit.emit(text, m_active_channel, m_replying_to); // m_replying_to is checked for invalid in the handler
if (m_is_replying)
diff --git a/discord/discord.cpp b/discord/discord.cpp
index 4596204..1869a59 100644
--- a/discord/discord.cpp
+++ b/discord/discord.cpp
@@ -1039,6 +1039,9 @@ void DiscordClient::HandleGatewayMessage(std::string str) {
case GatewayEvent::GUILD_JOIN_REQUEST_DELETE: {
HandleGatewayGuildJoinRequestDelete(m);
} break;
+ case GatewayEvent::RELATIONSHIP_REMOVE: {
+ HandleGatewayRelationshipRemove(m);
+ } break;
}
} break;
default:
@@ -1480,6 +1483,12 @@ void DiscordClient::HandleGatewayGuildJoinRequestDelete(const GatewayMessage &ms
m_signal_guild_join_request_delete.emit(data);
}
+void DiscordClient::HandleGatewayRelationshipRemove(const GatewayMessage &msg) {
+ RelationshipRemoveData data = msg.Data;
+ m_user_relationships.erase(data.ID);
+ m_signal_relationship_remove.emit(data.ID, data.Type);
+}
+
void DiscordClient::HandleGatewayReadySupplemental(const GatewayMessage &msg) {
ReadySupplementalData data = msg.Data;
for (const auto &p : data.MergedPresences.Friends) {
@@ -1815,6 +1824,7 @@ void DiscordClient::LoadEventMap() {
m_event_map["GUILD_JOIN_REQUEST_CREATE"] = GatewayEvent::GUILD_JOIN_REQUEST_CREATE;
m_event_map["GUILD_JOIN_REQUEST_UPDATE"] = GatewayEvent::GUILD_JOIN_REQUEST_UPDATE;
m_event_map["GUILD_JOIN_REQUEST_DELETE"] = GatewayEvent::GUILD_JOIN_REQUEST_DELETE;
+ m_event_map["RELATIONSHIP_REMOVE"] = GatewayEvent::RELATIONSHIP_REMOVE;
}
DiscordClient::type_signal_gateway_ready DiscordClient::signal_gateway_ready() {
@@ -1937,6 +1947,10 @@ DiscordClient::type_signal_guild_join_request_delete DiscordClient::signal_guild
return m_signal_guild_join_request_delete;
}
+DiscordClient::type_signal_relationship_remove DiscordClient::signal_relationship_remove() {
+ return m_signal_relationship_remove;
+}
+
DiscordClient::type_signal_message_sent DiscordClient::signal_message_sent() {
return m_signal_message_sent;
}
diff --git a/discord/discord.hpp b/discord/discord.hpp
index b3dced1..ee0a8f3 100644
--- a/discord/discord.hpp
+++ b/discord/discord.hpp
@@ -223,6 +223,7 @@ private:
void HandleGatewayGuildJoinRequestCreate(const GatewayMessage &msg);
void HandleGatewayGuildJoinRequestUpdate(const GatewayMessage &msg);
void HandleGatewayGuildJoinRequestDelete(const GatewayMessage &msg);
+ void HandleGatewayRelationshipRemove(const GatewayMessage &msg);
void HandleGatewayReadySupplemental(const GatewayMessage &msg);
void HandleGatewayReconnect(const GatewayMessage &msg);
void HandleGatewayInvalidSession(const GatewayMessage &msg);
@@ -314,6 +315,7 @@ public:
typedef sigc::signal<void, GuildJoinRequestCreateData> type_signal_guild_join_request_create;
typedef sigc::signal<void, GuildJoinRequestUpdateData> type_signal_guild_join_request_update;
typedef sigc::signal<void, GuildJoinRequestDeleteData> type_signal_guild_join_request_delete;
+ typedef sigc::signal<void, Snowflake, RelationshipType> type_signal_relationship_remove;
typedef sigc::signal<void, Message> type_signal_message_sent;
typedef sigc::signal<void, std::string /* nonce */, float /* retry_after */> type_signal_message_send_fail; // retry after param will be 0 if it failed for a reason that isnt slowmode
typedef sigc::signal<void, bool, GatewayCloseCode> type_signal_disconnected; // bool true if reconnecting
@@ -347,6 +349,7 @@ public:
type_signal_guild_join_request_create signal_guild_join_request_create();
type_signal_guild_join_request_update signal_guild_join_request_update();
type_signal_guild_join_request_delete signal_guild_join_request_delete();
+ type_signal_relationship_remove signal_relationship_remove();
type_signal_message_sent signal_message_sent();
type_signal_message_send_fail signal_message_send_fail();
type_signal_disconnected signal_disconnected();
@@ -381,6 +384,7 @@ protected:
type_signal_guild_join_request_create m_signal_guild_join_request_create;
type_signal_guild_join_request_update m_signal_guild_join_request_update;
type_signal_guild_join_request_delete m_signal_guild_join_request_delete;
+ type_signal_relationship_remove m_signal_relationship_remove;
type_signal_message_sent m_signal_message_sent;
type_signal_message_send_fail m_signal_message_send_fail;
type_signal_disconnected m_signal_disconnected;
diff --git a/discord/objects.cpp b/discord/objects.cpp
index d2a3f4c..9db6cf8 100644
--- a/discord/objects.cpp
+++ b/discord/objects.cpp
@@ -452,3 +452,8 @@ void from_json(const nlohmann::json &j, RateLimitedResponse &m) {
JS_O("message", m.Message);
JS_D("retry_after", m.RetryAfter);
}
+
+void from_json(const nlohmann::json &j, RelationshipRemoveData &m) {
+ JS_D("id", m.ID);
+ JS_D("type", m.Type);
+}
diff --git a/discord/objects.hpp b/discord/objects.hpp
index 5335dc0..2c6ac4c 100644
--- a/discord/objects.hpp
+++ b/discord/objects.hpp
@@ -68,6 +68,7 @@ enum class GatewayEvent : int {
GUILD_JOIN_REQUEST_CREATE,
GUILD_JOIN_REQUEST_UPDATE,
GUILD_JOIN_REQUEST_DELETE,
+ RELATIONSHIP_REMOVE,
};
enum class GatewayCloseCode : uint16_t {
@@ -626,3 +627,10 @@ struct RateLimitedResponse {
friend void from_json(const nlohmann::json &j, RateLimitedResponse &m);
};
+
+struct RelationshipRemoveData {
+ Snowflake ID;
+ RelationshipType Type;
+
+ friend void from_json(const nlohmann::json &j, RelationshipRemoveData &m);
+};