2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-08-31 06:26:18 +00:00

Add create poll box from groups three-dot menu.

This commit is contained in:
John Preston
2018-12-20 20:02:44 +04:00
parent 74c1db740d
commit b6f7832745
15 changed files with 752 additions and 52 deletions

View File

@@ -12,6 +12,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "boxes/mute_settings_box.h"
#include "boxes/add_contact_box.h"
#include "boxes/report_box.h"
#include "boxes/create_poll_box.h"
#include "boxes/peer_list_controllers.h"
#include "boxes/peers/manage_peer_box.h"
#include "boxes/peers/edit_peer_info_box.h"
@@ -360,6 +361,11 @@ void Filler::addChatActions(not_null<ChatData*> chat) {
lang(lng_profile_add_participant),
[chat] { AddChatMembers(chat); });
}
if (chat->canWrite()) {
_addAction(
lang(lng_polls_create),
[=] { PeerMenuCreatePoll(chat); });
}
_addAction(
lang(lng_profile_export_chat),
[=] { PeerMenuExportChat(chat); });
@@ -397,6 +403,11 @@ void Filler::addChannelActions(not_null<ChannelData*> channel) {
lang(lng_channel_add_members),
[channel] { PeerMenuAddChannelMembers(channel); });
}
if (channel->canWrite()) {
_addAction(
lang(lng_polls_create),
[=] { PeerMenuCreatePoll(channel); });
}
_addAction(
lang(isGroup
? lng_profile_export_chat
@@ -615,6 +626,19 @@ void PeerMenuShareContactBox(not_null<UserData*> user) {
}));
}
void PeerMenuCreatePoll(not_null<PeerData*> peer) {
const auto box = Ui::show(Box<CreatePollBox>());
box->submitRequests(
) | rpl::start_with_next([=](const PollData &result) {
const auto options = ApiWrap::SendOptions(App::history(peer));
Auth().api().createPoll(result, options, crl::guard(box, [=] {
box->closeBox();
}), crl::guard(box, [=](const RPCError &error) {
box->submitFailed(lang(lng_attach_failed));
}));
}, box->lifetime());
}
QPointer<Ui::RpWidget> ShowForwardMessagesBox(
MessageIdsList &&items,
FnMut<void()> &&successCallback) {

View File

@@ -50,6 +50,7 @@ void PeerMenuShareContactBox(not_null<UserData*> user);
void PeerMenuAddContact(not_null<UserData*> user);
void PeerMenuAddChannelMembers(not_null<ChannelData*> channel);
//void PeerMenuUngroupFeed(not_null<Data::Feed*> feed); // #feed
void PeerMenuCreatePoll(not_null<PeerData*> peer);
//void ToggleChannelGrouping(not_null<ChannelData*> channel, bool group); // #feed
Fn<void()> ClearHistoryHandler(not_null<PeerData*> peer);