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

View file

@ -26,6 +26,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "data/data_session.h"
#include "window/window_controller.h"
#include "window/window_session_controller.h"
#include "window/window_session_controller_link_info.h"
#include "styles/style_layers.h"
namespace {
@ -209,8 +210,7 @@ void MentionClickHandler::onClick(ClickContext context) const {
? Core::App().activeWindow()->sessionController()
: nullptr;
if (use) {
using Info = Window::SessionNavigation::PeerByLinkInfo;
use->showPeerByLink(Info{
use->showPeerByLink(Window::PeerByLinkInfo{
.usernameOrId = _tag.mid(1),
.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/language_box.h"
#include "passport/passport_form_controller.h"
#include "window/window_session_controller.h"
#include "ui/toast/toast.h"
#include "data/data_session.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/view/media_view_open_common.h"
#include "window/window_session_controller.h"
#include "window/window_session_controller_link_info.h"
#include "window/window_controller.h"
#include "window/window_peer_menu.h"
#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 "history/history.h"
#include "history/history_item.h"
#include "base/qt/qt_common_adapters.h"
#include "apiwrap.h"
#include <QtGui/QGuiApplication>
@ -286,7 +285,7 @@ bool ShowWallPaper(
const auto params = url_parse_params(
match->captured(1),
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 gradient = params.value(u"gradient"_q);
const auto result = BackgroundPreviewBox::Start(
@ -418,22 +417,21 @@ bool ResolveUsernameOrPhone(
}
}
const auto myContext = context.value<ClickHandlerContext>();
using Navigation = Window::SessionNavigation;
controller->window().activate();
controller->showPeerByLink(Navigation::PeerByLinkInfo{
controller->showPeerByLink(Window::PeerByLinkInfo{
.usernameOrId = domain,
.phone = phone,
.messageId = post,
.storyId = storyId,
.repliesInfo = commentId
? Navigation::RepliesByLinkInfo{
Navigation::CommentId{ commentId }
? Window::RepliesByLinkInfo{
Window::CommentId{ commentId }
}
: threadId
? Navigation::RepliesByLinkInfo{
Navigation::ThreadId{ threadId }
? Window::RepliesByLinkInfo{
Window::ThreadId{ threadId }
}
: Navigation::RepliesByLinkInfo{ v::null },
: Window::RepliesByLinkInfo{ v::null },
.resolveType = resolveType,
.startToken = startToken,
.startAdminRights = adminRights,
@ -486,19 +484,18 @@ bool ResolvePrivatePost(
return false;
}
const auto my = context.value<ClickHandlerContext>();
using Navigation = Window::SessionNavigation;
controller->showPeerByLink(Navigation::PeerByLinkInfo{
controller->showPeerByLink(Window::PeerByLinkInfo{
.usernameOrId = channelId,
.messageId = msgId,
.repliesInfo = commentId
? Navigation::RepliesByLinkInfo{
Navigation::CommentId{ commentId }
? Window::RepliesByLinkInfo{
Window::CommentId{ commentId }
}
: threadId
? Navigation::RepliesByLinkInfo{
Navigation::ThreadId{ threadId }
? Window::RepliesByLinkInfo{
Window::ThreadId{ threadId }
}
: Navigation::RepliesByLinkInfo{ v::null },
: Window::RepliesByLinkInfo{ v::null },
.clickFromMessageId = my.itemId,
.clickFromAttachBotWebviewUrl = my.attachBotWebviewUrl,
});
@ -877,9 +874,8 @@ bool ResolveBoost(
: params.value(u"channel"_q);
const auto myContext = context.value<ClickHandlerContext>();
using Navigation = Window::SessionNavigation;
controller->window().activate();
controller->showPeerByLink(Navigation::PeerByLinkInfo{
controller->showPeerByLink(Window::PeerByLinkInfo{
.usernameOrId = (!domainParam.isEmpty()
? std::variant<QString, ChannelId>(domainParam)
: ChannelId(BareId(channelParam.toULongLong()))),

View file

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

View file

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

View file

@ -93,16 +93,7 @@ class SectionMemento;
class Controller;
class FiltersMenu;
enum class ResolveType {
Default,
BotApp,
BotStart,
AddToGroup,
AddToChannel,
ShareGame,
Mention,
Boost,
};
struct PeerByLinkInfo;
struct PeerThemeOverride {
PeerData *peer = nullptr;
@ -195,33 +186,6 @@ public:
const SectionShow &params = SectionShow()) = 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 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