2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-09-08 02:15:56 +00:00

Allow editing topic title and icon.

This commit is contained in:
John Preston
2022-09-27 16:05:47 +04:00
parent c90f879c96
commit 3b3792ef75
42 changed files with 603 additions and 190 deletions

View File

@@ -165,60 +165,4 @@ rpl::producer<> Forum::chatsListLoadedEvents() const {
return _chatsListLoadedEvents.events();
}
void ShowAddForumTopic(
not_null<Window::SessionController*> controller,
not_null<ChannelData*> forum) {
controller->show(Box([=](not_null<Ui::GenericBox*> box) {
box->setTitle(rpl::single(u"New Topic"_q));
const auto title = box->addRow(
object_ptr<Ui::InputField>(
box,
st::defaultInputField,
rpl::single(u"Topic Title"_q))); // #TODO forum lang
const auto message = box->addRow(
object_ptr<Ui::InputField>(
box,
st::newGroupDescription,
Ui::InputField::Mode::MultiLine,
rpl::single(u"Message"_q))); // #TODO forum lang
box->setFocusCallback([=] {
title->setFocusFast();
});
box->addButton(tr::lng_create_group_create(), [=] {
if (!forum->isForum()) {
box->closeBox();
return;
} else if (title->getLastText().trimmed().isEmpty()) {
title->setFocus();
return;
} else if (message->getLastText().trimmed().isEmpty()) {
message->setFocus();
return;
}
const auto randomId = base::RandomValue<uint64>();
const auto api = &forum->session().api();
api->request(MTPchannels_CreateForumTopic(
MTP_flags(0),
forum->inputChannel,
MTP_string(title->getLastText().trimmed()),
MTPlong(), // icon_emoji_id
MTPInputMedia(),
MTP_string(message->getLastText().trimmed()),
MTP_long(randomId),
MTPVector<MTPMessageEntity>(),
MTPInputPeer() // send_as
)).done([=](const MTPUpdates &result) {
api->applyUpdates(result, randomId);
box->closeBox();
}).fail([=](const MTP::Error &error) {
api->sendMessageFail(error, forum, randomId);
}).send();
});
box->addButton(tr::lng_cancel(), [=] {
box->closeBox();
});
}), Ui::LayerOption::KeepOther);
}
} // namespace Data