diff options
author | ouwou <26526779+ouwou@users.noreply.github.com> | 2021-08-21 03:53:53 -0400 |
---|---|---|
committer | ouwou <26526779+ouwou@users.noreply.github.com> | 2021-08-21 03:53:53 -0400 |
commit | 962cda957d21e633e3f3ecea5c0e3e84a782d367 (patch) | |
tree | aa1f1bb74b264b14499a286c46ab0088d223aa49 | |
parent | 8059e524f166cdcb08f5ee7f3a3c8e72ffdd5d5b (diff) | |
parent | 5c63fe94874b7629da28813d6c7363a002ed5fee (diff) | |
download | abaddon-portaudio-962cda957d21e633e3f3ecea5c0e3e84a782d367.tar.gz abaddon-portaudio-962cda957d21e633e3f3ecea5c0e3e84a782d367.zip |
merge master
-rw-r--r-- | components/chatlist.cpp | 10 | ||||
-rw-r--r-- | windows/mainwindow.cpp | 7 | ||||
-rw-r--r-- | windows/pinnedwindow.cpp | 5 |
3 files changed, 14 insertions, 8 deletions
diff --git a/components/chatlist.cpp b/components/chatlist.cpp index 86460b9..ba10de9 100644 --- a/components/chatlist.cpp +++ b/components/chatlist.cpp @@ -168,18 +168,22 @@ void ChatList::ProcessNewMessage(const Message &data, bool prepend) { const auto &client = Abaddon::Get().GetDiscordClient(); const auto data = client.GetMessage(id); if (!data.has_value()) return false; + const auto channel = client.GetChannel(m_active_channel); + + bool is_dm = channel.has_value() && (channel->Type == ChannelType::DM || channel->Type == ChannelType::GROUP_DM); + const bool has_manage = client.HasChannelPermission(client.GetUserData().ID, m_active_channel, Permission::MANAGE_MESSAGES); m_menu_edit_message->set_visible(!m_use_pinned_menu); m_menu_reply_to->set_visible(!m_use_pinned_menu); - m_menu_unpin->set_visible(data->IsPinned); - m_menu_pin->set_visible(!data->IsPinned); + m_menu_unpin->set_visible((is_dm || has_manage) && data->IsPinned); + m_menu_pin->set_visible((is_dm || has_manage) && !data->IsPinned); if (data->IsDeleted()) { m_menu_delete_message->set_sensitive(false); m_menu_edit_message->set_sensitive(false); } else { const bool can_edit = client.GetUserData().ID == data->Author.ID; - const bool can_delete = can_edit || client.HasChannelPermission(client.GetUserData().ID, m_active_channel, Permission::MANAGE_MESSAGES); + const bool can_delete = can_edit || has_manage; m_menu_delete_message->set_sensitive(can_delete); m_menu_edit_message->set_sensitive(can_edit); } diff --git a/windows/mainwindow.cpp b/windows/mainwindow.cpp index 7ddaaf2..0bfff7c 100644 --- a/windows/mainwindow.cpp +++ b/windows/mainwindow.cpp @@ -244,16 +244,15 @@ void MainWindow::OnDiscordSubmenuPopup(const Gdk::Rectangle *flipped_rect, const m_menu_discord_set_status.set_sensitive(discord_active); } -void MainWindow::OnViewSubmenuPopup(const Gdk::Rectangle *flipped_rect, const Gdk::Rectangle *final_rect, bool flipped_x, bool flipped_y) { +void MainWindow::OnViewSubmenuPopup(const Gdk::Rectangle* flipped_rect, const Gdk::Rectangle* final_rect, bool flipped_x, bool flipped_y) { m_menu_view_friends.set_sensitive(Abaddon::Get().GetDiscordClient().IsStarted()); auto channel_id = GetChatActiveChannel(); auto channel = Abaddon::Get().GetDiscordClient().GetChannel(channel_id); m_menu_view_pins.set_sensitive(false); m_menu_view_threads.set_sensitive(false); if (channel.has_value()) { - const bool b = channel->Type == ChannelType::GUILD_TEXT; - m_menu_view_pins.set_sensitive(b); - m_menu_view_threads.set_sensitive(b); + m_menu_view_threads.set_sensitive(channel->Type == ChannelType::GUILD_TEXT); + m_menu_view_pins.set_sensitive(channel->Type == ChannelType::GUILD_TEXT || channel->Type == ChannelType::DM || channel->Type == ChannelType::GROUP_DM); } } diff --git a/windows/pinnedwindow.cpp b/windows/pinnedwindow.cpp index fc6230c..2e9b6fd 100644 --- a/windows/pinnedwindow.cpp +++ b/windows/pinnedwindow.cpp @@ -8,7 +8,10 @@ PinnedWindow::PinnedWindow(const ChannelData &data) set_name("pinned-messages"); set_default_size(450, 375); - set_title("#" + *data.Name + " - Pinned Messages"); + if (data.Name.has_value()) + set_title("#" + *data.Name + " - Pinned Messages"); + else + set_title("Pinned Messages"); set_position(Gtk::WIN_POS_CENTER); get_style_context()->add_class("app-window"); get_style_context()->add_class("app-popup"); |