summaryrefslogtreecommitdiff
path: root/src/components
diff options
context:
space:
mode:
authorouwou <26526779+ouwou@users.noreply.github.com>2022-05-06 01:14:15 -0400
committerouwou <26526779+ouwou@users.noreply.github.com>2022-05-06 01:14:15 -0400
commit2c25319fb85e077f27c3a4cd0bfdc8f503c6020d (patch)
treee92422ddcb896fb6b5bb75576138100c4f32f43d /src/components
parent7daa0a250c76247c883cf536a3d339016a3852b4 (diff)
downloadabaddon-portaudio-2c25319fb85e077f27c3a4cd0bfdc8f503c6020d.tar.gz
abaddon-portaudio-2c25319fb85e077f27c3a4cd0bfdc8f503c6020d.zip
clear tabs when access lost, show blanks for missing channels
Diffstat (limited to 'src/components')
-rw-r--r--src/components/channels.cpp5
-rw-r--r--src/components/channeltabswitcherhandy.cpp14
-rw-r--r--src/components/channeltabswitcherhandy.hpp2
-rw-r--r--src/components/memberlist.cpp5
4 files changed, 23 insertions, 3 deletions
diff --git a/src/components/channels.cpp b/src/components/channels.cpp
index 2b83eb0..4e2e4df 100644
--- a/src/components/channels.cpp
+++ b/src/components/channels.cpp
@@ -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");
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;
}
diff --git a/src/components/channeltabswitcherhandy.hpp b/src/components/channeltabswitcherhandy.hpp
index 561d463..6da9b17 100644
--- a/src/components/channeltabswitcherhandy.hpp
+++ b/src/components/channeltabswitcherhandy.hpp
@@ -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;
diff --git a/src/components/memberlist.cpp b/src/components/memberlist.cpp
index 4c95b63..85ccd05 100644
--- a/src/components/memberlist.cpp
+++ b/src/components/memberlist.cpp
@@ -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);