clear tabs when access lost, show blanks for missing channels

This commit is contained in:
ouwou
2022-05-06 01:14:15 -04:00
parent 7daa0a250c
commit 2c25319fb8
7 changed files with 68 additions and 7 deletions

View File

@@ -931,7 +931,10 @@ void ChannelList::OnChannelSubmenuPopup() {
const auto iter = m_model->get_iter(m_path_for_menu);
if (!iter) return;
const auto id = static_cast<Snowflake>((*iter)[m_columns.m_id]);
if (Abaddon::Get().GetDiscordClient().IsChannelMuted(id))
auto &discord = Abaddon::Get().GetDiscordClient();
const auto perms = discord.HasChannelPermission(discord.GetUserData().ID, id, Permission::VIEW_CHANNEL);
m_menu_channel_open_tab.set_sensitive(perms);
if (discord.IsChannelMuted(id))
m_menu_channel_toggle_mute.set_label("Unmute");
else
m_menu_channel_toggle_mute.set_label("Mute");

View File

@@ -37,6 +37,8 @@ ChannelTabSwitcherHandy::ChannelTabSwitcherHandy() {
discord.signal_message_ack().connect([this](const MessageAckData &data) {
CheckUnread(data.ChannelID);
});
discord.signal_channel_accessibility_changed().connect(sigc::mem_fun(*this, &ChannelTabSwitcherHandy::OnChannelAccessibilityChanged));
}
void ChannelTabSwitcherHandy::AddChannelTab(Snowflake id) {
@@ -195,6 +197,18 @@ void ChannelTabSwitcherHandy::AdvanceOnCurrent(size_t by) {
history->second.CurrentVisitedIndex = real;
}
void ChannelTabSwitcherHandy::OnChannelAccessibilityChanged(Snowflake id, bool accessibility) {
if (accessibility) return;
if (auto it = m_pages.find(id); it != m_pages.end()) {
if (hdy_tab_page_get_selected(it->second))
if (!hdy_tab_view_select_previous_page(m_tab_view))
hdy_tab_view_select_next_page(m_tab_view);
hdy_tab_view_close_page(m_tab_view, it->second);
ClearPage(it->second);
}
}
ChannelTabSwitcherHandy::type_signal_channel_switched_to ChannelTabSwitcherHandy::signal_channel_switched_to() {
return m_signal_channel_switched_to;
}

View File

@@ -35,6 +35,8 @@ private:
void AppendPageHistory(HdyTabPage *page, Snowflake channel);
void AdvanceOnCurrent(size_t by);
void OnChannelAccessibilityChanged(Snowflake id, bool accessibility);
HdyTabBar *m_tab_bar;
Gtk::Widget *m_tab_bar_wrapped;
HdyTabView *m_tab_view;

View File

@@ -160,10 +160,11 @@ void MemberList::UpdateMemberList() {
}
int num_rows = 0;
const auto guild = *discord.GetGuild(m_guild_id);
const auto guild = discord.GetGuild(m_guild_id);
if (!guild.has_value()) return;
auto add_user = [this, &num_rows, guild](const UserData &data) -> bool {
if (num_rows++ > MaxMemberListRows) return false;
auto *row = Gtk::manage(new MemberListUserRow(guild, data));
auto *row = Gtk::manage(new MemberListUserRow(*guild, data));
m_id_to_row[data.ID] = row;
AttachUserMenuHandler(row, data.ID);
m_listbox->add(*row);