mirror of
https://github.com/celisej567/abaddon.git
synced 2026-09-13 20:18:50 +03:00
remove temp attachment files when theyre actually done being uploaded
This commit is contained in:
@@ -112,6 +112,13 @@ void ChatInputAttachmentContainer::Clear() {
|
||||
m_attachments.clear();
|
||||
}
|
||||
|
||||
void ChatInputAttachmentContainer::ClearNoPurge() {
|
||||
for (auto *item : m_attachments) {
|
||||
delete item;
|
||||
}
|
||||
m_attachments.clear();
|
||||
}
|
||||
|
||||
bool ChatInputAttachmentContainer::AddImage(const Glib::RefPtr<Gdk::Pixbuf> &pb) {
|
||||
if (m_attachments.size() == 10) return false;
|
||||
|
||||
@@ -217,8 +224,8 @@ ChatInput::ChatInput()
|
||||
const auto attachments = m_attachments.GetFilePaths();
|
||||
bool b = m_signal_submit.emit(input, attachments);
|
||||
if (b) {
|
||||
m_attachments.Clear();
|
||||
m_attachments_revealer.set_reveal_child(false);
|
||||
m_attachments.ClearNoPurge();
|
||||
}
|
||||
return b;
|
||||
});
|
||||
@@ -232,7 +239,9 @@ ChatInput::ChatInput()
|
||||
show_all_children();
|
||||
|
||||
m_input.signal_image_paste().connect([this](const Glib::RefPtr<Gdk::Pixbuf> &pb) {
|
||||
if (m_attachments.AddImage(pb))
|
||||
const bool can_attach_files = m_signal_check_permission.emit(Permission::ATTACH_FILES);
|
||||
|
||||
if (can_attach_files && m_attachments.AddImage(pb))
|
||||
m_attachments_revealer.set_reveal_child(true);
|
||||
});
|
||||
|
||||
@@ -266,3 +275,7 @@ ChatInput::type_signal_submit ChatInput::signal_submit() {
|
||||
ChatInput::type_signal_escape ChatInput::signal_escape() {
|
||||
return m_signal_escape;
|
||||
}
|
||||
|
||||
ChatInput::type_signal_check_permission ChatInput::signal_check_permission() {
|
||||
return m_signal_check_permission;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#pragma once
|
||||
#include <gtkmm.h>
|
||||
#include "discord/permissions.hpp"
|
||||
|
||||
class ChatInputAttachmentItem : public Gtk::EventBox {
|
||||
public:
|
||||
@@ -32,6 +33,7 @@ public:
|
||||
ChatInputAttachmentContainer();
|
||||
|
||||
void Clear();
|
||||
void ClearNoPurge();
|
||||
bool AddImage(const Glib::RefPtr<Gdk::Pixbuf> &pb);
|
||||
[[nodiscard]] std::vector<std::string> GetFilePaths() const;
|
||||
|
||||
@@ -98,11 +100,14 @@ public:
|
||||
// maybe this should be reduced to a single struct, its bound to get more complicated (application commands?)
|
||||
using type_signal_submit = sigc::signal<bool, Glib::ustring, std::vector<std::string>>;
|
||||
using type_signal_escape = sigc::signal<void>;
|
||||
using type_signal_check_permission = sigc::signal<bool, Permission>;
|
||||
|
||||
type_signal_submit signal_submit();
|
||||
type_signal_escape signal_escape();
|
||||
type_signal_check_permission signal_check_permission();
|
||||
|
||||
private:
|
||||
type_signal_submit m_signal_submit;
|
||||
type_signal_escape m_signal_escape;
|
||||
type_signal_check_permission m_signal_check_permission;
|
||||
};
|
||||
|
||||
@@ -47,6 +47,9 @@ ChatWindow::ChatWindow() {
|
||||
|
||||
m_input->set_valign(Gtk::ALIGN_END);
|
||||
|
||||
m_input->signal_check_permission().connect([this](Permission perm) {
|
||||
return Abaddon::Get().GetDiscordClient().HasSelfChannelPermission(m_active_channel, perm);
|
||||
});
|
||||
m_input->signal_submit().connect(sigc::mem_fun(*this, &ChatWindow::OnInputSubmit));
|
||||
m_input->signal_escape().connect([this]() {
|
||||
if (m_is_replying)
|
||||
|
||||
Reference in New Issue
Block a user