mirror of
https://github.com/kotatogram/kotatogram-desktop
synced 2025-08-31 06:35:14 +00:00
Pass Main::Session to click handler creators.
This commit is contained in:
@@ -120,7 +120,7 @@ auto MentionClickHandler::getTextEntity() const -> TextEntity {
|
||||
void MentionNameClickHandler::onClick(ClickContext context) const {
|
||||
const auto button = context.button;
|
||||
if (button == Qt::LeftButton || button == Qt::MiddleButton) {
|
||||
if (auto user = Auth().data().userLoaded(_userId)) {
|
||||
if (auto user = _session->data().userLoaded(_userId)) {
|
||||
Ui::showPeerProfile(user);
|
||||
}
|
||||
}
|
||||
@@ -132,7 +132,7 @@ auto MentionNameClickHandler::getTextEntity() const -> TextEntity {
|
||||
}
|
||||
|
||||
QString MentionNameClickHandler::tooltip() const {
|
||||
if (const auto user = Auth().data().userLoaded(_userId)) {
|
||||
if (const auto user = _session->data().userLoaded(_userId)) {
|
||||
const auto name = user->name;
|
||||
if (name != _text) {
|
||||
return name;
|
||||
|
@@ -9,6 +9,10 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
|
||||
#include "ui/basic_click_handlers.h"
|
||||
|
||||
namespace Main {
|
||||
class Session;
|
||||
} // namespace Main
|
||||
|
||||
class HiddenUrlClickHandler : public UrlClickHandler {
|
||||
public:
|
||||
HiddenUrlClickHandler(QString url) : UrlClickHandler(url, false) {
|
||||
@@ -72,8 +76,13 @@ private:
|
||||
|
||||
class MentionNameClickHandler : public ClickHandler {
|
||||
public:
|
||||
MentionNameClickHandler(QString text, UserId userId, uint64 accessHash)
|
||||
: _text(text)
|
||||
MentionNameClickHandler(
|
||||
not_null<Main::Session*> session,
|
||||
QString text,
|
||||
UserId userId,
|
||||
uint64 accessHash)
|
||||
: _session(session)
|
||||
, _text(text)
|
||||
, _userId(userId)
|
||||
, _accessHash(accessHash) {
|
||||
}
|
||||
@@ -85,6 +94,7 @@ public:
|
||||
QString tooltip() const override;
|
||||
|
||||
private:
|
||||
const not_null<Main::Session*> _session;
|
||||
QString _text;
|
||||
UserId _userId;
|
||||
uint64 _accessHash;
|
||||
|
@@ -112,8 +112,11 @@ std::shared_ptr<ClickHandler> UiIntegration::createLinkHandler(
|
||||
|
||||
case EntityType::MentionName: {
|
||||
auto fields = TextUtilities::MentionNameDataToFields(data.data);
|
||||
if (fields.userId) {
|
||||
if (!my || !my->session) {
|
||||
LOG(("Mention name without a session: %1").arg(data.data));
|
||||
} else if (fields.userId) {
|
||||
return std::make_shared<MentionNameClickHandler>(
|
||||
my->session,
|
||||
data.text,
|
||||
fields.userId,
|
||||
fields.accessHash);
|
||||
|
@@ -9,6 +9,10 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
|
||||
#include "ui/integration.h"
|
||||
|
||||
namespace Main {
|
||||
class Session;
|
||||
} // namespace Main
|
||||
|
||||
namespace Core {
|
||||
|
||||
class UiIntegration : public Ui::Integration {
|
||||
@@ -19,6 +23,7 @@ public:
|
||||
Instagram,
|
||||
};
|
||||
struct Context {
|
||||
Main::Session *session = nullptr;
|
||||
HashtagMentionType type = HashtagMentionType::Telegram;
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user