Redraw unread indicator after message status for category changes

This commit is contained in:
Jerzy Kozera
2023-07-04 22:00:22 +02:00
parent 3f6be457b1
commit bdad178c5d
2 changed files with 16 additions and 7 deletions

View File

@@ -1102,15 +1102,25 @@ void ChannelList::SetDMChannelIcon(Gtk::TreeIter iter, const ChannelData &dm) {
} }
} }
void ChannelList::RedrawUnreadIndicatorsForChannel(const ChannelData &channel) {
if (channel.GuildID.has_value()) {
auto iter = GetIteratorForGuildFromID(*channel.GuildID);
if (iter) m_model->row_changed(m_model->get_path(iter), iter);
}
if (channel.ParentID.has_value()) {
auto iter = GetIteratorForRowFromIDOfType(*channel.ParentID, RenderType::Category);
if (iter) m_model->row_changed(m_model->get_path(iter), iter);
}
}
void ChannelList::OnMessageAck(const MessageAckData &data) { void ChannelList::OnMessageAck(const MessageAckData &data) {
// trick renderer into redrawing // trick renderer into redrawing
m_model->row_changed(Gtk::TreeModel::Path("0"), m_model->get_iter("0")); // 0 is always path for dm header m_model->row_changed(Gtk::TreeModel::Path("0"), m_model->get_iter("0")); // 0 is always path for dm header
auto iter = GetIteratorForRowFromID(data.ChannelID); auto iter = GetIteratorForRowFromID(data.ChannelID);
if (iter) m_model->row_changed(m_model->get_path(iter), iter); if (iter) m_model->row_changed(m_model->get_path(iter), iter);
auto channel = Abaddon::Get().GetDiscordClient().GetChannel(data.ChannelID); auto channel = Abaddon::Get().GetDiscordClient().GetChannel(data.ChannelID);
if (channel.has_value() && channel->GuildID.has_value()) { if (channel.has_value()) {
iter = GetIteratorForGuildFromID(*channel->GuildID); RedrawUnreadIndicatorsForChannel(*channel);
if (iter) m_model->row_changed(m_model->get_path(iter), iter);
} }
} }
@@ -1123,9 +1133,7 @@ void ChannelList::OnMessageCreate(const Message &msg) {
if (iter) if (iter)
(*iter)[m_columns.m_sort] = static_cast<int64_t>(-msg.ID); (*iter)[m_columns.m_sort] = static_cast<int64_t>(-msg.ID);
} }
if (channel->GuildID.has_value()) RedrawUnreadIndicatorsForChannel(*channel);
if ((iter = GetIteratorForGuildFromID(*channel->GuildID)))
m_model->row_changed(m_model->get_path(iter), iter);
} }
bool ChannelList::OnButtonPressEvent(GdkEventButton *ev) { bool ChannelList::OnButtonPressEvent(GdkEventButton *ev) {

View File

@@ -116,9 +116,10 @@ protected:
void UpdateCreateDMChannel(const ChannelData &channel); void UpdateCreateDMChannel(const ChannelData &channel);
void SetDMChannelIcon(Gtk::TreeIter iter, const ChannelData &dm); void SetDMChannelIcon(Gtk::TreeIter iter, const ChannelData &dm);
void RedrawUnreadIndicatorsForChannel(const ChannelData& channel);
void OnMessageAck(const MessageAckData &data); void OnMessageAck(const MessageAckData &data);
void OnMessageCreate(const Message &msg); void OnMessageCreate(const Message &msg);
Gtk::TreeModel::Path m_path_for_menu; Gtk::TreeModel::Path m_path_for_menu;
// cant be recovered through selection // cant be recovered through selection