show unread indicators for threads

This commit is contained in:
ouwou
2022-01-20 01:34:36 -05:00
parent 6c9bf4ff81
commit dfd642bb82
2 changed files with 37 additions and 1 deletions

View File

@@ -438,7 +438,39 @@ void CellRendererChannels::render_vfunc_thread(const Cairo::RefPtr<Cairo::Contex
const int text_h = natural_size.height;
Gdk::Rectangle text_cell_area(text_x, text_y, text_w, text_h);
auto &discord = Abaddon::Get().GetDiscordClient();
const auto id = m_property_id.get_value();
const bool is_muted = discord.IsChannelMuted(id);
static Gdk::RGBA muted_color("#7f7f7f");
if (discord.IsChannelMuted(m_property_id.get_value()))
m_renderer_text.property_foreground_rgba() = muted_color;
m_renderer_text.render(cr, widget, background_area, text_cell_area, flags);
m_renderer_text.property_foreground_set() = false;
// unread
const auto unread_state = discord.GetUnreadStateForChannel(id);
if (unread_state < 0) return;
if (!is_muted) {
cr->set_source_rgb(1.0, 1.0, 1.0);
const auto x = background_area.get_x();
const auto y = background_area.get_y();
const auto w = background_area.get_width();
const auto h = background_area.get_height();
cr->rectangle(x, y, 3, h);
cr->fill();
}
if (unread_state < 1) return;
auto *paned = static_cast<Gtk::Paned *>(widget.get_ancestor(Gtk::Paned::get_type()));
if (paned != nullptr) {
const auto edge = std::min(paned->get_position(), cell_area.get_width());
unread_render_mentions(cr, widget, unread_state, edge, cell_area);
}
}
// dm header

View File

@@ -2343,10 +2343,14 @@ void DiscordClient::StoreMessageData(Message &msg) {
// here the absence of an entry in m_unread indicates a read channel and the value is only the mention count since the message doesnt matter
// no entry.id cannot be a guild even though sometimes it looks like it
void DiscordClient::HandleReadyReadState(const ReadyEventData &data) {
for (const auto &guild : data.Guilds)
for (const auto &guild : data.Guilds) {
for (const auto &channel : *guild.Channels)
if (channel.LastMessageID.has_value())
m_last_message_id[channel.ID] = *channel.LastMessageID;
for (const auto &thread : *guild.Threads)
if (thread.LastMessageID.has_value())
m_last_message_id[thread.ID] = *thread.LastMessageID;
}
for (const auto &channel : data.PrivateChannels)
if (channel.LastMessageID.has_value())
m_last_message_id[channel.ID] = *channel.LastMessageID;