mirror of
https://github.com/uowuo/abaddon.git
synced 2024-09-20 06:51:51 +00:00
check nitro size restriction + fix replying border
This commit is contained in:
parent
241d9a2140
commit
02ce353c6d
|
@ -102,12 +102,17 @@
|
|||
background-color: #242424;
|
||||
color: #adadad;
|
||||
border-radius: 15px;
|
||||
border: 1px solid transparent;
|
||||
}
|
||||
|
||||
.message-input.replying {
|
||||
border: 1px solid #026FB9;
|
||||
}
|
||||
|
||||
.message-input.bad-input {
|
||||
border: 1px solid #dd3300;
|
||||
}
|
||||
|
||||
.message-input {
|
||||
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) {
|
||||
try {
|
||||
const auto read_stream = file->read();
|
||||
|
|
|
@ -102,6 +102,10 @@ public:
|
|||
Glib::RefPtr<Gtk::TextBuffer> GetBuffer();
|
||||
bool ProcessKeyPress(GdkEventKey *event);
|
||||
void AddAttachment(const Glib::RefPtr<Gio::File> &file);
|
||||
void IndicateTooLarge();
|
||||
|
||||
void StartReplying();
|
||||
void StopReplying();
|
||||
|
||||
private:
|
||||
bool AddFileAsImageAttachment(const Glib::RefPtr<Gio::File> &file);
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
#include "ratelimitindicator.hpp"
|
||||
#include "chatinput.hpp"
|
||||
#include "chatlist.hpp"
|
||||
#include "constants.hpp"
|
||||
#ifdef WITH_LIBHANDY
|
||||
#include "channeltabswitcherhandy.hpp"
|
||||
#endif
|
||||
|
@ -222,6 +223,24 @@ Snowflake ChatWindow::GetActiveChannel() const {
|
|||
}
|
||||
|
||||
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())
|
||||
return false;
|
||||
|
||||
|
@ -255,8 +274,7 @@ void ChatWindow::StartReplying(Snowflake message_id) {
|
|||
const auto author = discord.GetUser(message.Author.ID);
|
||||
m_replying_to = message_id;
|
||||
m_is_replying = true;
|
||||
m_input->grab_focus();
|
||||
m_input->get_style_context()->add_class("replying");
|
||||
m_input->StartReplying();
|
||||
if (author.has_value())
|
||||
m_input_indicator->SetCustomMarkup("Replying to " + author->GetEscapedBoldString<false>());
|
||||
else
|
||||
|
@ -266,7 +284,7 @@ void ChatWindow::StartReplying(Snowflake message_id) {
|
|||
void ChatWindow::StopReplying() {
|
||||
m_is_replying = false;
|
||||
m_replying_to = Snowflake::Invalid;
|
||||
m_input->get_style_context()->remove_class("replying");
|
||||
m_input->StopReplying();
|
||||
m_input_indicator->ClearCustom();
|
||||
}
|
||||
|
||||
|
|
|
@ -3,3 +3,8 @@
|
|||
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 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;
|
||||
|
|
Loading…
Reference in New Issue
Block a user