Moved out PeerByLinkInfo from SessionNavigation to separate file.

This commit is contained in:
23rd 2023-11-23 16:03:25 +03:00 committed by John Preston
parent 3f19dc0486
commit d28ba4fad9
8 changed files with 79 additions and 68 deletions

View file

@ -1449,6 +1449,7 @@ PRIVATE
window/window_section_common.h window/window_section_common.h
window/window_session_controller.cpp window/window_session_controller.cpp
window/window_session_controller.h window/window_session_controller.h
window/window_session_controller_link_info.h
window/window_slide_animation.cpp window/window_slide_animation.cpp
window/window_slide_animation.h window/window_slide_animation.h
window/window_top_bar_wrap.h window/window_top_bar_wrap.h

View file

@ -8,7 +8,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "boxes/peers/edit_peer_reactions.h" #include "boxes/peers/edit_peer_reactions.h"
#include "base/event_filter.h" #include "base/event_filter.h"
#include "boxes/reactions_settings_box.h" // AddReactionAnimatedIcon
#include "chat_helpers/tabbed_panel.h" #include "chat_helpers/tabbed_panel.h"
#include "chat_helpers/tabbed_selector.h" #include "chat_helpers/tabbed_selector.h"
#include "data/data_message_reactions.h" #include "data/data_message_reactions.h"
@ -30,6 +29,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "ui/wrap/slide_wrap.h" #include "ui/wrap/slide_wrap.h"
#include "ui/vertical_list.h" #include "ui/vertical_list.h"
#include "window/window_session_controller.h" #include "window/window_session_controller.h"
#include "window/window_session_controller_link_info.h"
#include "styles/style_chat_helpers.h" #include "styles/style_chat_helpers.h"
#include "styles/style_info.h" #include "styles/style_info.h"
#include "styles/style_settings.h" #include "styles/style_settings.h"
@ -492,7 +492,7 @@ void AddReactionsText(
const auto count = inner->lifetime().make_state<rpl::variable<int>>( const auto count = inner->lifetime().make_state<rpl::variable<int>>(
std::move(customCountValue)); std::move(customCountValue));
auto outer = container->add( container->add(
object_ptr<Ui::DividerLabel>( object_ptr<Ui::DividerLabel>(
container, container,
std::move(ownedInner), std::move(ownedInner),
@ -510,8 +510,7 @@ void AddReactionsText(
const auto weak = base::make_weak(navigation); const auto weak = base::make_weak(navigation);
label->setClickHandlerFilter([=](const auto &...) { label->setClickHandlerFilter([=](const auto &...) {
if (const auto strong = weak.get()) { if (const auto strong = weak.get()) {
using Info = Window::SessionNavigation::PeerByLinkInfo; strong->showPeerByLink(Window::PeerByLinkInfo{
strong->showPeerByLink(Info{
.usernameOrId = u"stickers"_q, .usernameOrId = u"stickers"_q,
.resolveType = Window::ResolveType::Mention, .resolveType = Window::ResolveType::Mention,
}); });
@ -563,7 +562,6 @@ void EditAllowedReactionsBox(
using namespace Data; using namespace Data;
using namespace rpl::mappers; using namespace rpl::mappers;
const auto iconHeight = st::editPeerReactionsPreview;
box->setTitle(tr::lng_manage_peer_reactions()); box->setTitle(tr::lng_manage_peer_reactions());
box->setWidth(st::boxWideWidth); box->setWidth(st::boxWideWidth);
@ -707,7 +705,6 @@ void EditAllowedReactionsBox(
state->customCount.value(), state->customCount.value(),
args.askForBoosts); args.askForBoosts);
} }
const auto total = int(all.size());
const auto collect = [=] { const auto collect = [=] {
auto result = AllowedReactions(); auto result = AllowedReactions();
if (isGroup if (isGroup

View file

@ -26,6 +26,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "data/data_session.h" #include "data/data_session.h"
#include "window/window_controller.h" #include "window/window_controller.h"
#include "window/window_session_controller.h" #include "window/window_session_controller.h"
#include "window/window_session_controller_link_info.h"
#include "styles/style_layers.h" #include "styles/style_layers.h"
namespace { namespace {
@ -209,8 +210,7 @@ void MentionClickHandler::onClick(ClickContext context) const {
? Core::App().activeWindow()->sessionController() ? Core::App().activeWindow()->sessionController()
: nullptr; : nullptr;
if (use) { if (use) {
using Info = Window::SessionNavigation::PeerByLinkInfo; use->showPeerByLink(Window::PeerByLinkInfo{
use->showPeerByLink(Info{
.usernameOrId = _tag.mid(1), .usernameOrId = _tag.mid(1),
.resolveType = Window::ResolveType::Mention, .resolveType = Window::ResolveType::Mention,
}); });

View file

@ -29,7 +29,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "boxes/sessions_box.h" #include "boxes/sessions_box.h"
#include "boxes/language_box.h" #include "boxes/language_box.h"
#include "passport/passport_form_controller.h" #include "passport/passport_form_controller.h"
#include "window/window_session_controller.h"
#include "ui/toast/toast.h" #include "ui/toast/toast.h"
#include "data/data_session.h" #include "data/data_session.h"
#include "data/data_document.h" #include "data/data_document.h"
@ -38,6 +37,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "media/player/media_player_instance.h" #include "media/player/media_player_instance.h"
#include "media/view/media_view_open_common.h" #include "media/view/media_view_open_common.h"
#include "window/window_session_controller.h" #include "window/window_session_controller.h"
#include "window/window_session_controller_link_info.h"
#include "window/window_controller.h" #include "window/window_controller.h"
#include "window/window_peer_menu.h" #include "window/window_peer_menu.h"
#include "window/themes/window_theme_editor_box.h" // GenerateSlug. #include "window/themes/window_theme_editor_box.h" // GenerateSlug.
@ -57,7 +57,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "inline_bots/bot_attach_web_view.h" #include "inline_bots/bot_attach_web_view.h"
#include "history/history.h" #include "history/history.h"
#include "history/history_item.h" #include "history/history_item.h"
#include "base/qt/qt_common_adapters.h"
#include "apiwrap.h" #include "apiwrap.h"
#include <QtGui/QGuiApplication> #include <QtGui/QGuiApplication>
@ -286,7 +285,7 @@ bool ShowWallPaper(
const auto params = url_parse_params( const auto params = url_parse_params(
match->captured(1), match->captured(1),
qthelp::UrlParamNameTransform::ToLower); qthelp::UrlParamNameTransform::ToLower);
const auto bg = params.value(u"bg_color"_q); // const auto bg = params.value(u"bg_color"_q);
const auto color = params.value(u"color"_q); const auto color = params.value(u"color"_q);
const auto gradient = params.value(u"gradient"_q); const auto gradient = params.value(u"gradient"_q);
const auto result = BackgroundPreviewBox::Start( const auto result = BackgroundPreviewBox::Start(
@ -418,22 +417,21 @@ bool ResolveUsernameOrPhone(
} }
} }
const auto myContext = context.value<ClickHandlerContext>(); const auto myContext = context.value<ClickHandlerContext>();
using Navigation = Window::SessionNavigation;
controller->window().activate(); controller->window().activate();
controller->showPeerByLink(Navigation::PeerByLinkInfo{ controller->showPeerByLink(Window::PeerByLinkInfo{
.usernameOrId = domain, .usernameOrId = domain,
.phone = phone, .phone = phone,
.messageId = post, .messageId = post,
.storyId = storyId, .storyId = storyId,
.repliesInfo = commentId .repliesInfo = commentId
? Navigation::RepliesByLinkInfo{ ? Window::RepliesByLinkInfo{
Navigation::CommentId{ commentId } Window::CommentId{ commentId }
} }
: threadId : threadId
? Navigation::RepliesByLinkInfo{ ? Window::RepliesByLinkInfo{
Navigation::ThreadId{ threadId } Window::ThreadId{ threadId }
} }
: Navigation::RepliesByLinkInfo{ v::null }, : Window::RepliesByLinkInfo{ v::null },
.resolveType = resolveType, .resolveType = resolveType,
.startToken = startToken, .startToken = startToken,
.startAdminRights = adminRights, .startAdminRights = adminRights,
@ -486,19 +484,18 @@ bool ResolvePrivatePost(
return false; return false;
} }
const auto my = context.value<ClickHandlerContext>(); const auto my = context.value<ClickHandlerContext>();
using Navigation = Window::SessionNavigation; controller->showPeerByLink(Window::PeerByLinkInfo{
controller->showPeerByLink(Navigation::PeerByLinkInfo{
.usernameOrId = channelId, .usernameOrId = channelId,
.messageId = msgId, .messageId = msgId,
.repliesInfo = commentId .repliesInfo = commentId
? Navigation::RepliesByLinkInfo{ ? Window::RepliesByLinkInfo{
Navigation::CommentId{ commentId } Window::CommentId{ commentId }
} }
: threadId : threadId
? Navigation::RepliesByLinkInfo{ ? Window::RepliesByLinkInfo{
Navigation::ThreadId{ threadId } Window::ThreadId{ threadId }
} }
: Navigation::RepliesByLinkInfo{ v::null }, : Window::RepliesByLinkInfo{ v::null },
.clickFromMessageId = my.itemId, .clickFromMessageId = my.itemId,
.clickFromAttachBotWebviewUrl = my.attachBotWebviewUrl, .clickFromAttachBotWebviewUrl = my.attachBotWebviewUrl,
}); });
@ -877,9 +874,8 @@ bool ResolveBoost(
: params.value(u"channel"_q); : params.value(u"channel"_q);
const auto myContext = context.value<ClickHandlerContext>(); const auto myContext = context.value<ClickHandlerContext>();
using Navigation = Window::SessionNavigation;
controller->window().activate(); controller->window().activate();
controller->showPeerByLink(Navigation::PeerByLinkInfo{ controller->showPeerByLink(Window::PeerByLinkInfo{
.usernameOrId = (!domainParam.isEmpty() .usernameOrId = (!domainParam.isEmpty()
? std::variant<QString, ChannelId>(domainParam) ? std::variant<QString, ChannelId>(domainParam)
: ChannelId(BareId(channelParam.toULongLong()))), : ChannelId(BareId(channelParam.toULongLong()))),

View file

@ -52,10 +52,10 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "ui/vertical_list.h" #include "ui/vertical_list.h"
#include "window/window_controller.h" #include "window/window_controller.h"
#include "window/window_session_controller.h" #include "window/window_session_controller.h"
#include "window/window_session_controller_link_info.h"
#include "base/unixtime.h" #include "base/unixtime.h"
#include "apiwrap.h" #include "apiwrap.h"
#include "api/api_premium.h" #include "api/api_premium.h"
#include "styles/style_boxes.h"
#include "styles/style_premium.h" #include "styles/style_premium.h"
#include "styles/style_info.h" #include "styles/style_info.h"
#include "styles/style_intro.h" #include "styles/style_intro.h"
@ -104,8 +104,8 @@ namespace Gift {
struct Data { struct Data {
PeerId peerId; PeerId peerId;
int months; int months = 0;
bool me; bool me = false;
explicit operator bool() const { explicit operator bool() const {
return peerId != 0; return peerId != 0;
@ -1448,7 +1448,7 @@ void StartPremiumPayment(
"premium_invoice_slug", "premium_invoice_slug",
QString()); QString());
if (!username.isEmpty()) { if (!username.isEmpty()) {
controller->showPeerByLink(Window::SessionNavigation::PeerByLinkInfo{ controller->showPeerByLink(Window::PeerByLinkInfo{
.usernameOrId = username, .usernameOrId = username,
.resolveType = Window::ResolveType::BotStart, .resolveType = Window::ResolveType::BotStart,
.startToken = ref, .startToken = ref,

View file

@ -83,6 +83,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "storage/file_upload.h" #include "storage/file_upload.h"
#include "window/themes/window_theme.h" #include "window/themes/window_theme.h"
#include "window/window_peer_menu.h" #include "window/window_peer_menu.h"
#include "window/window_session_controller_link_info.h"
#include "settings/settings_main.h" #include "settings/settings_main.h"
#include "settings/settings_premium.h" #include "settings/settings_premium.h"
#include "settings/settings_privacy_security.h" #include "settings/settings_privacy_security.h"

View file

@ -93,16 +93,7 @@ class SectionMemento;
class Controller; class Controller;
class FiltersMenu; class FiltersMenu;
enum class ResolveType { struct PeerByLinkInfo;
Default,
BotApp,
BotStart,
AddToGroup,
AddToChannel,
ShareGame,
Mention,
Boost,
};
struct PeerThemeOverride { struct PeerThemeOverride {
PeerData *peer = nullptr; PeerData *peer = nullptr;
@ -195,33 +186,6 @@ public:
const SectionShow &params = SectionShow()) = 0; const SectionShow &params = SectionShow()) = 0;
virtual not_null<SessionController*> parentController() = 0; virtual not_null<SessionController*> parentController() = 0;
struct CommentId {
MsgId id = 0;
};
struct ThreadId {
MsgId id = 0;
};
using RepliesByLinkInfo = std::variant<v::null_t, CommentId, ThreadId>;
struct PeerByLinkInfo {
std::variant<QString, ChannelId> usernameOrId;
QString phone;
MsgId messageId = ShowAtUnreadMsgId;
StoryId storyId = 0;
RepliesByLinkInfo repliesInfo;
ResolveType resolveType = ResolveType::Default;
QString startToken;
ChatAdminRights startAdminRights;
bool startAutoSubmit = false;
QString botAppName;
bool botAppForceConfirmation = false;
QString attachBotUsername;
std::optional<QString> attachBotToggleCommand;
bool attachBotMenuOpen = false;
InlineBots::PeerTypes attachBotChooseTypes;
std::optional<QString> voicechatHash;
FullMsgId clickFromMessageId;
QString clickFromAttachBotWebviewUrl;
};
void showPeerByLink(const PeerByLinkInfo &info); void showPeerByLink(const PeerByLinkInfo &info);
void showRepliesForMessage( void showRepliesForMessage(

View file

@ -0,0 +1,52 @@
/*
This file is part of Telegram Desktop,
the official desktop application for the Telegram messaging service.
For license and copyright information please follow this link:
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
*/
#pragma once
namespace Window {
enum class ResolveType {
Default,
BotApp,
BotStart,
AddToGroup,
AddToChannel,
ShareGame,
Mention,
Boost,
};
struct CommentId {
MsgId id = 0;
};
struct ThreadId {
MsgId id = 0;
};
using RepliesByLinkInfo = std::variant<v::null_t, CommentId, ThreadId>;
struct PeerByLinkInfo {
std::variant<QString, ChannelId> usernameOrId;
QString phone;
MsgId messageId = ShowAtUnreadMsgId;
StoryId storyId = 0;
RepliesByLinkInfo repliesInfo;
ResolveType resolveType = ResolveType::Default;
QString startToken;
ChatAdminRights startAdminRights;
bool startAutoSubmit = false;
QString botAppName;
bool botAppForceConfirmation = false;
QString attachBotUsername;
std::optional<QString> attachBotToggleCommand;
bool attachBotMenuOpen = false;
InlineBots::PeerTypes attachBotChooseTypes;
std::optional<QString> voicechatHash;
FullMsgId clickFromMessageId;
QString clickFromAttachBotWebviewUrl;
};
} // namespace Window