From 59acd0f82f500d743ca4be7324f913903c8de237 Mon Sep 17 00:00:00 2001 From: ouwou <26526779+ouwou@users.noreply.github.com> Date: Sat, 23 Jul 2022 18:34:33 -0400 Subject: handle max message payload + show filename label --- src/components/chatwindow.cpp | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'src/components/chatwindow.cpp') diff --git a/src/components/chatwindow.cpp b/src/components/chatwindow.cpp index 38e0247..b68ceba 100644 --- a/src/components/chatwindow.cpp +++ b/src/components/chatwindow.cpp @@ -250,11 +250,20 @@ bool ChatWindow::OnInputSubmit(ChatSubmitParams data) { int restriction = std::max(nitro_restriction, guild_restriction); + goffset total_size = 0; 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 (info) { + const auto size = info->get_size(); + if (size > restriction) { + m_input->IndicateTooLarge(); + return false; + } + total_size += size; + if (total_size > MaxMessagePayloadSize) { + m_input->IndicateTooLarge(); + return false; + } } } -- cgit v1.2.3