mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2026-07-25 06:54:43 +00:00
Initial support for managed bot creation.
This commit is contained in:
@@ -79,6 +79,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
#include "ui/rect.h"
|
||||
#include "ui/ui_utility.h"
|
||||
#include "ui/text/format_values.h"
|
||||
#include "ui/text/text_utilities.h"
|
||||
#include "ui/text/text_variant.h"
|
||||
#include "ui/toast/toast.h"
|
||||
#include "ui/vertical_list.h"
|
||||
@@ -95,6 +96,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
#include "window/window_controller.h" // Window::Controller::show.
|
||||
#include "window/window_peer_menu.h"
|
||||
#include "window/window_session_controller.h"
|
||||
#include "styles/style_boxes.h"
|
||||
#include "styles/style_channel_earn.h" // st::channelEarnCurrencyCommonMargins
|
||||
#include "styles/style_info.h"
|
||||
#include "styles/style_layers.h"
|
||||
@@ -1218,7 +1220,7 @@ public:
|
||||
private:
|
||||
object_ptr<Ui::RpWidget> setupPersonalChannel(not_null<UserData*> user);
|
||||
object_ptr<Ui::RpWidget> setupInfo();
|
||||
void setupMainApp();
|
||||
void setupMainApp(bool suppressBottom = false);
|
||||
void setupBotPermissions();
|
||||
void addShowTopicsListButton(
|
||||
Ui::MultiSlideTracker &tracker,
|
||||
@@ -2124,7 +2126,7 @@ object_ptr<Ui::RpWidget> DetailsFiller::setupPersonalChannel(
|
||||
return result;
|
||||
}
|
||||
|
||||
void DetailsFiller::setupMainApp() {
|
||||
void DetailsFiller::setupMainApp(bool suppressBottom) {
|
||||
const auto button = _wrap->add(
|
||||
object_ptr<Ui::RoundButton>(
|
||||
_wrap,
|
||||
@@ -2148,6 +2150,9 @@ void DetailsFiller::setupMainApp() {
|
||||
});
|
||||
|
||||
const auto url = tr::lng_mini_apps_tos_url(tr::now);
|
||||
const auto parts = suppressBottom
|
||||
? RectPart::Top
|
||||
: (RectPart::Top | RectPart::Bottom);
|
||||
const auto divider = Ui::AddDividerText(
|
||||
_wrap,
|
||||
rpl::combine(
|
||||
@@ -2163,7 +2168,10 @@ void DetailsFiller::setupMainApp() {
|
||||
text = text.append(u"\n\n"_q).append(verify->description);
|
||||
}
|
||||
return text;
|
||||
}));
|
||||
}),
|
||||
st::defaultBoxDividerLabelPadding,
|
||||
st::defaultDividerLabel,
|
||||
parts);
|
||||
divider->setClickHandlerFilter([=](const auto &...) {
|
||||
UrlClickHandler::Open(url);
|
||||
return false;
|
||||
@@ -2370,12 +2378,48 @@ object_ptr<Ui::RpWidget> DetailsFiller::fill() {
|
||||
if (const auto info = user->botInfo.get()) {
|
||||
if (info->hasMainApp) {
|
||||
_dividerOverridden.force_assign(true);
|
||||
setupMainApp();
|
||||
const auto managedBotFollows = user->botManagerId()
|
||||
&& !info->canManageEmojiStatus
|
||||
&& user->owner().userLoaded(user->botManagerId());
|
||||
setupMainApp(managedBotFollows);
|
||||
}
|
||||
if (info->canManageEmojiStatus) {
|
||||
_dividerOverridden.force_assign(false);
|
||||
setupBotPermissions();
|
||||
}
|
||||
if (user->botManagerId()) {
|
||||
if (const auto managerUser = user->owner().userLoaded(
|
||||
user->botManagerId())) {
|
||||
if (!info->hasMainApp) {
|
||||
_dividerOverridden.force_assign(true);
|
||||
}
|
||||
const auto botUsername = managerUser->username();
|
||||
const auto linkText = botUsername.isEmpty()
|
||||
? managerUser->name()
|
||||
: (u"@"_q + botUsername);
|
||||
const auto parts = (info->hasMainApp && !info->canManageEmojiStatus)
|
||||
? RectPart::Bottom
|
||||
: (RectPart::Top | RectPart::Bottom);
|
||||
const auto divider = Ui::AddDividerText(
|
||||
_wrap,
|
||||
tr::lng_managed_bot_label(
|
||||
lt_icon,
|
||||
rpl::single(Ui::Text::IconEmoji(&st::managedBotIconEmoji)),
|
||||
lt_bot,
|
||||
rpl::single(tr::link(linkText)),
|
||||
tr::marked),
|
||||
st::defaultBoxDividerLabelPadding,
|
||||
st::defaultDividerLabel,
|
||||
parts);
|
||||
const auto weak = base::make_weak(_controller);
|
||||
divider->setClickHandlerFilter([=](const auto &...) {
|
||||
if (const auto strong = weak.get()) {
|
||||
strong->showPeerInfo(managerUser);
|
||||
}
|
||||
return false;
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!user->isSelf() && !_sublist) {
|
||||
addReportReaction(_mainTracker, &lastButtonTracker);
|
||||
|
||||
Reference in New Issue
Block a user