mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-16 14:17:12 +02:00
Improve topic three-dot menu.
This commit is contained in:
parent
03c08ad95f
commit
fba0f0c49b
4 changed files with 33 additions and 12 deletions
|
@ -223,6 +223,11 @@ bool ForumTopic::canWrite() const {
|
|||
&& (!closed() || canToggleClosed());
|
||||
}
|
||||
|
||||
bool ForumTopic::canSendPolls() const {
|
||||
return canWrite()
|
||||
&& !channel()->amRestricted(ChatRestriction::SendPolls);
|
||||
}
|
||||
|
||||
bool ForumTopic::canEdit() const {
|
||||
return my() || channel()->canManageTopics();
|
||||
}
|
||||
|
|
|
@ -65,6 +65,7 @@ public:
|
|||
|
||||
[[nodiscard]] bool my() const;
|
||||
[[nodiscard]] bool canWrite() const;
|
||||
[[nodiscard]] bool canSendPolls() const;
|
||||
[[nodiscard]] bool canEdit() const;
|
||||
[[nodiscard]] bool canToggleClosed() const;
|
||||
[[nodiscard]] bool canTogglePinned() const;
|
||||
|
|
|
@ -1024,17 +1024,34 @@ void TopBarWidget::updateControlsVisibility() {
|
|||
if (_unreadBadge) {
|
||||
_unreadBadge->setVisible(!_chooseForReportReason);
|
||||
}
|
||||
const auto topic = _activeChat.key.topic();
|
||||
const auto section = _activeChat.section;
|
||||
const auto historyMode = (section == Section::History);
|
||||
const auto hasPollsMenu = _activeChat.key.peer()
|
||||
&& _activeChat.key.peer()->canSendPolls();
|
||||
const auto hasPollsMenu = (_activeChat.key.peer()
|
||||
&& _activeChat.key.peer()->canSendPolls())
|
||||
|| (topic && topic->canSendPolls());
|
||||
const auto hasTopicMenu = [&] {
|
||||
if (!topic) {
|
||||
return false;
|
||||
}
|
||||
auto empty = true;
|
||||
const auto callback = [&](const Ui::Menu::MenuCallback::Args&) {
|
||||
empty = false;
|
||||
return (QAction*)nullptr;
|
||||
};
|
||||
Window::FillDialogsEntryMenu(
|
||||
_controller,
|
||||
_activeChat,
|
||||
Ui::Menu::MenuCallback(callback));
|
||||
return !empty;
|
||||
}();
|
||||
const auto hasMenu = !_activeChat.key.folder()
|
||||
&& (section == Section::History
|
||||
? true
|
||||
: (section == Section::Scheduled)
|
||||
? hasPollsMenu
|
||||
: (section == Section::Replies)
|
||||
? (hasPollsMenu || _activeChat.key.topic())
|
||||
? (hasPollsMenu || hasTopicMenu)
|
||||
: (section == Section::ChatsList)
|
||||
? (_activeChat.key.peer() && _activeChat.key.peer()->isForum())
|
||||
: false);
|
||||
|
|
|
@ -937,7 +937,7 @@ void Filler::addManageChat() {
|
|||
}
|
||||
|
||||
void Filler::addCreatePoll() {
|
||||
if (!_peer->canSendPolls()) {
|
||||
if (!(_topic ? _topic->canSendPolls() : _peer->canSendPolls())) {
|
||||
return;
|
||||
}
|
||||
const auto peer = _peer;
|
||||
|
@ -1044,7 +1044,6 @@ void Filler::addCreateTopic() {
|
|||
}
|
||||
const auto peer = _peer;
|
||||
const auto controller = _controller;
|
||||
_addAction(PeerMenuCallback::Args{ .isSeparator = true });
|
||||
_addAction(tr::lng_forum_create_topic(tr::now), [=] {
|
||||
if (const auto forum = peer->forum()) {
|
||||
controller->show(Box(
|
||||
|
@ -1053,6 +1052,7 @@ void Filler::addCreateTopic() {
|
|||
forum->history()));
|
||||
}
|
||||
}, &st::menuIconDiscussion);
|
||||
_addAction(PeerMenuCallback::Args{ .isSeparator = true });
|
||||
}
|
||||
|
||||
void Filler::addViewAsMessages() {
|
||||
|
@ -1064,7 +1064,6 @@ void Filler::addViewAsMessages() {
|
|||
_addAction(tr::lng_forum_view_as_messages(tr::now), [=] {
|
||||
controller->showPeerHistory(peer->id);
|
||||
}, &st::menuIconViewReplies);
|
||||
_addAction(PeerMenuCallback::Args{ .isSeparator = true });
|
||||
}
|
||||
|
||||
void Filler::addSearchTopics() {
|
||||
|
@ -1083,22 +1082,22 @@ void Filler::fillChatsListActions() {
|
|||
if (!_peer || !_peer->isForum()) {
|
||||
return;
|
||||
}
|
||||
addViewAsMessages();
|
||||
if (FillVideoChatMenu(_controller, _request, _addAction)) {
|
||||
_addAction(PeerMenuCallback::Args{ .isSeparator = true });
|
||||
}
|
||||
addCreateTopic();
|
||||
addInfo();
|
||||
addViewAsMessages();
|
||||
addManageChat();
|
||||
FillVideoChatMenu(_controller, _request, _addAction);
|
||||
addNewMembers();
|
||||
const auto &all = _peer->forum()->topicsList()->indexed()->all();
|
||||
if (all.size() > kTopicsSearchMinCount) {
|
||||
addSearchTopics();
|
||||
}
|
||||
_addAction(PeerMenuCallback::Args{ .isSeparator = true });
|
||||
if (_peer->asChannel()->amIn()) {
|
||||
addLeaveChat();
|
||||
} else {
|
||||
addJoinChat();
|
||||
}
|
||||
addCreateTopic();
|
||||
}
|
||||
|
||||
void Filler::fillContextMenuActions() {
|
||||
|
@ -1163,7 +1162,6 @@ void Filler::fillRepliesActions() {
|
|||
if (_topic) {
|
||||
addInfo();
|
||||
addManageTopic();
|
||||
addManageChat();
|
||||
}
|
||||
addCreatePoll();
|
||||
addToggleTopicClosed();
|
||||
|
|
Loading…
Add table
Reference in a new issue