From 2c25319fb85e077f27c3a4cd0bfdc8f503c6020d Mon Sep 17 00:00:00 2001 From: ouwou <26526779+ouwou@users.noreply.github.com> Date: Fri, 6 May 2022 01:14:15 -0400 Subject: clear tabs when access lost, show blanks for missing channels --- src/components/channeltabswitcherhandy.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'src/components/channeltabswitcherhandy.cpp') diff --git a/src/components/channeltabswitcherhandy.cpp b/src/components/channeltabswitcherhandy.cpp index f7b0226..67dbff0 100644 --- a/src/components/channeltabswitcherhandy.cpp +++ b/src/components/channeltabswitcherhandy.cpp @@ -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; } -- cgit v1.2.3