mirror of
https://github.com/uowuo/abaddon.git
synced 2026-08-15 05:19:58 +00:00
show count of unread dms in header
This commit is contained in:
@@ -770,6 +770,7 @@ void ChannelList::UpdateCreateDMChannel(const ChannelData &dm) {
|
||||
|
||||
void ChannelList::OnMessageAck(const MessageAckData &data) {
|
||||
// trick renderer into redrawing
|
||||
m_model->row_changed(Gtk::TreeModel::Path("0"), m_model->get_iter("0")); // 0 is always path for dm header
|
||||
auto iter = GetIteratorForChannelFromID(data.ChannelID);
|
||||
if (iter) m_model->row_changed(m_model->get_path(iter), iter);
|
||||
auto channel = Abaddon::Get().GetDiscordClient().GetChannel(data.ChannelID);
|
||||
|
||||
@@ -465,6 +465,13 @@ void CellRendererChannels::render_vfunc_dmheader(const Cairo::RefPtr<Cairo::Cont
|
||||
cell_area.get_x() + 9, cell_area.get_y(), // maybe theres a better way to align this ?
|
||||
cell_area.get_width(), cell_area.get_height());
|
||||
m_renderer_text.render(cr, widget, background_area, text_cell_area, flags);
|
||||
|
||||
auto *paned = static_cast<Gtk::Paned *>(widget.get_ancestor(Gtk::Paned::get_type()));
|
||||
if (paned != nullptr) {
|
||||
const auto edge = std::min(paned->get_position(), background_area.get_width());
|
||||
if (const auto unread = Abaddon::Get().GetDiscordClient().GetUnreadDMsCount(); unread > 0)
|
||||
unread_render_mentions(cr, widget, unread, edge, background_area);
|
||||
}
|
||||
}
|
||||
|
||||
// dm (basically the same thing as guild)
|
||||
|
||||
@@ -1202,6 +1202,14 @@ bool DiscordClient::GetUnreadStateForGuild(Snowflake id, int &total_mentions) co
|
||||
return has_any_unread;
|
||||
}
|
||||
|
||||
int DiscordClient::GetUnreadDMsCount() const {
|
||||
const auto channels = GetPrivateChannels();
|
||||
int count = 0;
|
||||
for (const auto channel_id : channels)
|
||||
if (GetUnreadStateForChannel(channel_id) > -1) count++;
|
||||
return count;
|
||||
}
|
||||
|
||||
PresenceStatus DiscordClient::GetUserStatus(Snowflake id) const {
|
||||
auto it = m_user_to_status.find(id);
|
||||
if (it != m_user_to_status.end())
|
||||
|
||||
@@ -194,6 +194,7 @@ public:
|
||||
bool IsGuildMuted(Snowflake id) const noexcept;
|
||||
int GetUnreadStateForChannel(Snowflake id) const noexcept;
|
||||
bool GetUnreadStateForGuild(Snowflake id, int &total_mentions) const noexcept;
|
||||
int GetUnreadDMsCount() const;
|
||||
|
||||
PresenceStatus GetUserStatus(Snowflake id) const;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user