merge master

This commit is contained in:
ouwou 2021-08-21 03:53:53 -04:00
commit 962cda957d
3 changed files with 14 additions and 8 deletions

View File

@ -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);
}

View File

@ -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);
}
}

View File

@ -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");