forked from OpenGamers/abaddon
add notice for archived threads at top of chatwindow
This commit is contained in:
parent
f3769ca301
commit
002004cb5f
14
abaddon.cpp
14
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);
|
||||
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user