summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorouwou <26526779+ouwou@users.noreply.github.com>2021-09-03 04:04:51 -0400
committerouwou <26526779+ouwou@users.noreply.github.com>2021-09-03 04:04:51 -0400
commit002004cb5f01d22601047433cc868359cf022842 (patch)
tree766d1605dfca4bd43c454cfca885f02a3aade70c
parentf3769ca30164b28538294c27dd3fdec672638631 (diff)
downloadabaddon-portaudio-002004cb5f01d22601047433cc868359cf022842.tar.gz
abaddon-portaudio-002004cb5f01d22601047433cc868359cf022842.zip
add notice for archived threads at top of chatwindow
-rw-r--r--abaddon.cpp14
-rw-r--r--abaddon.hpp1
-rw-r--r--components/chatwindow.cpp11
-rw-r--r--components/chatwindow.hpp4
4 files changed, 30 insertions, 0 deletions
diff --git a/abaddon.cpp b/abaddon.cpp
index 4ffa89a..5bf6771 100644
--- a/abaddon.cpp
+++ b/abaddon.cpp
@@ -40,6 +40,7 @@ Abaddon::Abaddon()
m_discord.signal_reaction_add().connect(sigc::mem_fun(*this, &Abaddon::DiscordOnReactionAdd));
m_discord.signal_reaction_remove().connect(sigc::mem_fun(*this, &Abaddon::DiscordOnReactionRemove));
m_discord.signal_guild_join_request_create().connect(sigc::mem_fun(*this, &Abaddon::DiscordOnGuildJoinRequestCreate));
+ m_discord.signal_thread_update().connect(sigc::mem_fun(*this, &Abaddon::DiscordOnThreadUpdate));
m_discord.signal_message_sent().connect(sigc::mem_fun(*this, &Abaddon::DiscordOnMessageSent));
m_discord.signal_disconnected().connect(sigc::mem_fun(*this, &Abaddon::DiscordOnDisconnect));
if (m_settings.GetPrefetch())
@@ -237,6 +238,15 @@ void Abaddon::DiscordOnDisconnect(bool is_reconnecting, GatewayCloseCode close_c
}
}
+void Abaddon::DiscordOnThreadUpdate(const ThreadUpdateData &data) {
+ if (data.Thread.ID == m_main_window->GetChatActiveChannel()) {
+ if (data.Thread.ThreadMetadata->IsArchived)
+ m_main_window->GetChatWindow()->SetTopic("This thread is archived. Sending a message will unarchive it");
+ else
+ m_main_window->GetChatWindow()->SetTopic("");
+ }
+}
+
const SettingsManager &Abaddon::GetSettings() const {
return m_settings;
}
@@ -453,6 +463,8 @@ void Abaddon::ActionJoinGuildDialog() {
void Abaddon::ActionChannelOpened(Snowflake id) {
if (id == m_main_window->GetChatActiveChannel()) return;
+ m_main_window->GetChatWindow()->SetTopic("");
+
const auto channel = m_discord.GetChannel(id);
if (!channel.has_value()) return;
if (channel->Type == ChannelType::GUILD_TEXT || channel->Type == ChannelType::GUILD_NEWS)
@@ -480,6 +492,8 @@ void Abaddon::ActionChannelOpened(Snowflake id) {
if (channel->IsThread()) {
m_discord.SendThreadLazyLoad(id);
+ if (channel->ThreadMetadata->IsArchived)
+ m_main_window->GetChatWindow()->SetTopic("This thread is archived. Sending a message will unarchive it");
} else if (channel->Type != ChannelType::DM && channel->Type != ChannelType::GROUP_DM && channel->GuildID.has_value()) {
m_discord.SendLazyLoad(id);
diff --git a/abaddon.hpp b/abaddon.hpp
index 2f203f7..92485fb 100644
--- a/abaddon.hpp
+++ b/abaddon.hpp
@@ -72,6 +72,7 @@ public:
void DiscordOnGuildJoinRequestCreate(const GuildJoinRequestCreateData &data);
void DiscordOnMessageSent(const Message &data);
void DiscordOnDisconnect(bool is_reconnecting, GatewayCloseCode close_code);
+ void DiscordOnThreadUpdate(const ThreadUpdateData &data);
const SettingsManager &GetSettings() const;
diff --git a/components/chatwindow.cpp b/components/chatwindow.cpp
index 57b412b..c2bd688 100644
--- a/components/chatwindow.cpp
+++ b/components/chatwindow.cpp
@@ -31,6 +31,11 @@ ChatWindow::ChatWindow() {
m_main->set_hexpand(true);
m_main->set_vexpand(true);
+ m_topic.get_style_context()->add_class("channel-topic");
+ m_topic.add(m_topic_text);
+ m_topic_text.set_halign(Gtk::ALIGN_START);
+ m_topic_text.show();
+
m_input->signal_submit().connect(sigc::mem_fun(*this, &ChatWindow::OnInputSubmit));
m_input->signal_escape().connect([this]() {
if (m_is_replying)
@@ -84,6 +89,7 @@ ChatWindow::ChatWindow() {
m_meta->add(*m_input_indicator);
m_meta->add(*m_rate_limit_indicator);
//m_scroll->add(*m_list);
+ m_main->add(m_topic);
m_main->add(*m_chat);
m_main->add(m_completer);
m_main->add(*m_input);
@@ -140,6 +146,11 @@ void ChatWindow::UpdateReactions(Snowflake id) {
m_chat->UpdateMessageReactions(id);
}
+void ChatWindow::SetTopic(const std::string &text) {
+ m_topic_text.set_text(text);
+ m_topic.set_visible(text.length() > 0);
+}
+
Snowflake ChatWindow::GetActiveChannel() const {
return m_active_channel;
}
diff --git a/components/chatwindow.hpp b/components/chatwindow.hpp
index ee2eef6..5ef8bad 100644
--- a/components/chatwindow.hpp
+++ b/components/chatwindow.hpp
@@ -28,6 +28,7 @@ public:
void InsertChatInput(std::string text);
Snowflake GetOldestListedMessage(); // oldest message that is currently in the ListBox
void UpdateReactions(Snowflake id);
+ void SetTopic(const std::string &text);
protected:
bool m_is_replying = false;
@@ -49,6 +50,9 @@ protected:
//Gtk::ListBox *m_list;
//Gtk::ScrolledWindow *m_scroll;
+ Gtk::EventBox m_topic; // todo probably make everything else go on the stack
+ Gtk::Label m_topic_text;
+
ChatList *m_chat;
ChatInput *m_input;