check nitro size restriction + fix replying border
This commit is contained in:
@@ -102,12 +102,17 @@
|
|||||||
background-color: #242424;
|
background-color: #242424;
|
||||||
color: #adadad;
|
color: #adadad;
|
||||||
border-radius: 15px;
|
border-radius: 15px;
|
||||||
|
border: 1px solid transparent;
|
||||||
}
|
}
|
||||||
|
|
||||||
.message-input.replying {
|
.message-input.replying {
|
||||||
border: 1px solid #026FB9;
|
border: 1px solid #026FB9;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.message-input.bad-input {
|
||||||
|
border: 1px solid #dd3300;
|
||||||
|
}
|
||||||
|
|
||||||
.message-input {
|
.message-input {
|
||||||
padding: 0px 0px 0px 5px;
|
padding: 0px 0px 0px 5px;
|
||||||
}
|
}
|
||||||
|
@@ -392,6 +392,23 @@ void ChatInput::AddAttachment(const Glib::RefPtr<Gio::File> &file) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ChatInput::IndicateTooLarge() {
|
||||||
|
m_input.get_style_context()->add_class("bad-input");
|
||||||
|
const auto cb = [this] {
|
||||||
|
m_input.get_style_context()->remove_class("bad-input");
|
||||||
|
};
|
||||||
|
Glib::signal_timeout().connect_seconds_once(sigc::track_obj(cb, *this), 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ChatInput::StartReplying() {
|
||||||
|
m_input.grab_focus();
|
||||||
|
m_input.get_style_context()->add_class("replying");
|
||||||
|
}
|
||||||
|
|
||||||
|
void ChatInput::StopReplying() {
|
||||||
|
m_input.get_style_context()->remove_class("replying");
|
||||||
|
}
|
||||||
|
|
||||||
bool ChatInput::AddFileAsImageAttachment(const Glib::RefPtr<Gio::File> &file) {
|
bool ChatInput::AddFileAsImageAttachment(const Glib::RefPtr<Gio::File> &file) {
|
||||||
try {
|
try {
|
||||||
const auto read_stream = file->read();
|
const auto read_stream = file->read();
|
||||||
|
@@ -102,6 +102,10 @@ public:
|
|||||||
Glib::RefPtr<Gtk::TextBuffer> GetBuffer();
|
Glib::RefPtr<Gtk::TextBuffer> GetBuffer();
|
||||||
bool ProcessKeyPress(GdkEventKey *event);
|
bool ProcessKeyPress(GdkEventKey *event);
|
||||||
void AddAttachment(const Glib::RefPtr<Gio::File> &file);
|
void AddAttachment(const Glib::RefPtr<Gio::File> &file);
|
||||||
|
void IndicateTooLarge();
|
||||||
|
|
||||||
|
void StartReplying();
|
||||||
|
void StopReplying();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool AddFileAsImageAttachment(const Glib::RefPtr<Gio::File> &file);
|
bool AddFileAsImageAttachment(const Glib::RefPtr<Gio::File> &file);
|
||||||
|
@@ -4,6 +4,7 @@
|
|||||||
#include "ratelimitindicator.hpp"
|
#include "ratelimitindicator.hpp"
|
||||||
#include "chatinput.hpp"
|
#include "chatinput.hpp"
|
||||||
#include "chatlist.hpp"
|
#include "chatlist.hpp"
|
||||||
|
#include "constants.hpp"
|
||||||
#ifdef WITH_LIBHANDY
|
#ifdef WITH_LIBHANDY
|
||||||
#include "channeltabswitcherhandy.hpp"
|
#include "channeltabswitcherhandy.hpp"
|
||||||
#endif
|
#endif
|
||||||
@@ -222,6 +223,24 @@ Snowflake ChatWindow::GetActiveChannel() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool ChatWindow::OnInputSubmit(ChatSubmitParams data) {
|
bool ChatWindow::OnInputSubmit(ChatSubmitParams data) {
|
||||||
|
int restriction = BaseAttachmentSizeLimit;
|
||||||
|
const auto nitro = Abaddon::Get().GetDiscordClient().GetUserData().PremiumType;
|
||||||
|
if (!nitro.has_value() || nitro == EPremiumType::None) {
|
||||||
|
restriction = BaseAttachmentSizeLimit;
|
||||||
|
} else if (nitro == EPremiumType::NitroClassic) {
|
||||||
|
restriction = NitroClassicAttachmentSizeLimit;
|
||||||
|
} else if (nitro == EPremiumType::Nitro) {
|
||||||
|
restriction = NitroAttachmentSizeLimit;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const auto &attachment : data.Attachments) {
|
||||||
|
const auto info = attachment.File->query_info();
|
||||||
|
if (info && info->get_size() > restriction) {
|
||||||
|
m_input->IndicateTooLarge();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!m_rate_limit_indicator->CanSpeak())
|
if (!m_rate_limit_indicator->CanSpeak())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
@@ -255,8 +274,7 @@ void ChatWindow::StartReplying(Snowflake message_id) {
|
|||||||
const auto author = discord.GetUser(message.Author.ID);
|
const auto author = discord.GetUser(message.Author.ID);
|
||||||
m_replying_to = message_id;
|
m_replying_to = message_id;
|
||||||
m_is_replying = true;
|
m_is_replying = true;
|
||||||
m_input->grab_focus();
|
m_input->StartReplying();
|
||||||
m_input->get_style_context()->add_class("replying");
|
|
||||||
if (author.has_value())
|
if (author.has_value())
|
||||||
m_input_indicator->SetCustomMarkup("Replying to " + author->GetEscapedBoldString<false>());
|
m_input_indicator->SetCustomMarkup("Replying to " + author->GetEscapedBoldString<false>());
|
||||||
else
|
else
|
||||||
@@ -266,7 +284,7 @@ void ChatWindow::StartReplying(Snowflake message_id) {
|
|||||||
void ChatWindow::StopReplying() {
|
void ChatWindow::StopReplying() {
|
||||||
m_is_replying = false;
|
m_is_replying = false;
|
||||||
m_replying_to = Snowflake::Invalid;
|
m_replying_to = Snowflake::Invalid;
|
||||||
m_input->get_style_context()->remove_class("replying");
|
m_input->StopReplying();
|
||||||
m_input_indicator->ClearCustom();
|
m_input_indicator->ClearCustom();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -3,3 +3,8 @@
|
|||||||
constexpr static uint64_t SnowflakeSplitDifference = 600;
|
constexpr static uint64_t SnowflakeSplitDifference = 600;
|
||||||
constexpr static int MaxMessagesForChatCull = 50; // this has to be 50 (for now) cuz that magic number is used in a couple other places and i dont feel like replacing them
|
constexpr static int MaxMessagesForChatCull = 50; // this has to be 50 (for now) cuz that magic number is used in a couple other places and i dont feel like replacing them
|
||||||
constexpr static int AttachmentItemSize = 128;
|
constexpr static int AttachmentItemSize = 128;
|
||||||
|
constexpr static int BaseAttachmentSizeLimit = 8 * 1024 * 1024;
|
||||||
|
constexpr static int NitroClassicAttachmentSizeLimit = 50 * 1024 * 1024;
|
||||||
|
constexpr static int NitroAttachmentSizeLimit = 100 * 1024 * 1024;
|
||||||
|
constexpr static int BoostLevel2AttachmentSizeLimit = 50 * 1024 * 1024;
|
||||||
|
constexpr static int BoostLevel3AttachmentSizeLimit = 100 * 1024 * 1024;
|
||||||
|
Reference in New Issue
Block a user