mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-16 06:07:06 +02:00
Pass Main::Session to click handler creators.
This commit is contained in:
parent
fc174f742a
commit
03dec15e8e
21 changed files with 117 additions and 93 deletions
|
@ -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;
|
||||
};
|
||||
|
||||
|
|
|
@ -301,8 +301,7 @@ QString DocumentFileNameForSave(
|
|||
DocumentClickHandler::DocumentClickHandler(
|
||||
not_null<DocumentData*> document,
|
||||
FullMsgId context)
|
||||
: FileClickHandler(context)
|
||||
, _session(&document->session())
|
||||
: FileClickHandler(&document->session(), context)
|
||||
, _document(document) {
|
||||
}
|
||||
|
||||
|
@ -353,9 +352,7 @@ void DocumentOpenClickHandler::Open(
|
|||
}
|
||||
|
||||
void DocumentOpenClickHandler::onClickImpl() const {
|
||||
if (valid()) {
|
||||
Open(context(), document(), getActionItem());
|
||||
}
|
||||
Open(context(), document(), getActionItem());
|
||||
}
|
||||
|
||||
void DocumentSaveClickHandler::Save(
|
||||
|
@ -393,16 +390,10 @@ void DocumentSaveClickHandler::Save(
|
|||
}
|
||||
|
||||
void DocumentSaveClickHandler::onClickImpl() const {
|
||||
if (valid()) {
|
||||
Save(context(), document());
|
||||
}
|
||||
Save(context(), document());
|
||||
}
|
||||
|
||||
void DocumentCancelClickHandler::onClickImpl() const {
|
||||
if (!valid()) {
|
||||
return;
|
||||
}
|
||||
|
||||
const auto data = document();
|
||||
if (!data->date) {
|
||||
return;
|
||||
|
@ -435,9 +426,7 @@ void DocumentOpenWithClickHandler::Open(
|
|||
}
|
||||
|
||||
void DocumentOpenWithClickHandler::onClickImpl() const {
|
||||
if (valid()) {
|
||||
Open(context(), document());
|
||||
}
|
||||
Open(context(), document());
|
||||
}
|
||||
|
||||
Data::FileOrigin StickerData::setOrigin() const {
|
||||
|
|
|
@ -335,16 +335,11 @@ public:
|
|||
not_null<DocumentData*> document,
|
||||
FullMsgId context = FullMsgId());
|
||||
|
||||
[[nodiscard]] bool valid() const {
|
||||
return !_session.empty();
|
||||
}
|
||||
|
||||
[[nodiscard]] not_null<DocumentData*> document() const {
|
||||
return _document;
|
||||
}
|
||||
|
||||
private:
|
||||
const base::weak_ptr<Main::Session> _session;
|
||||
const not_null<DocumentData*> _document;
|
||||
|
||||
};
|
||||
|
|
|
@ -329,22 +329,16 @@ PhotoClickHandler::PhotoClickHandler(
|
|||
not_null<PhotoData*> photo,
|
||||
FullMsgId context,
|
||||
PeerData *peer)
|
||||
: FileClickHandler(context)
|
||||
, _session(&photo->session())
|
||||
: FileClickHandler(&photo->session(), context)
|
||||
, _photo(photo)
|
||||
, _peer(peer) {
|
||||
}
|
||||
|
||||
void PhotoOpenClickHandler::onClickImpl() const {
|
||||
if (valid()) {
|
||||
Core::App().showPhoto(this);
|
||||
}
|
||||
Core::App().showPhoto(this);
|
||||
}
|
||||
|
||||
void PhotoSaveClickHandler::onClickImpl() const {
|
||||
if (!valid()) {
|
||||
return;
|
||||
}
|
||||
const auto data = photo();
|
||||
if (!data->date) {
|
||||
return;
|
||||
|
@ -354,9 +348,6 @@ void PhotoSaveClickHandler::onClickImpl() const {
|
|||
}
|
||||
|
||||
void PhotoCancelClickHandler::onClickImpl() const {
|
||||
if (!valid()) {
|
||||
return;
|
||||
}
|
||||
const auto data = photo();
|
||||
if (!data->date) {
|
||||
return;
|
||||
|
|
|
@ -145,10 +145,6 @@ public:
|
|||
FullMsgId context = FullMsgId(),
|
||||
PeerData *peer = nullptr);
|
||||
|
||||
[[nodiscard]] bool valid() const {
|
||||
return !_session.empty();
|
||||
}
|
||||
|
||||
[[nodiscard]] not_null<PhotoData*> photo() const {
|
||||
return _photo;
|
||||
}
|
||||
|
@ -157,7 +153,6 @@ public:
|
|||
}
|
||||
|
||||
private:
|
||||
const base::weak_ptr<Main::Session> _session;
|
||||
const not_null<PhotoData*> _photo;
|
||||
PeerData * const _peer = nullptr;
|
||||
|
||||
|
|
|
@ -136,7 +136,7 @@ void MessageCursor::applyTo(not_null<Ui::InputField*> field) {
|
|||
}
|
||||
|
||||
HistoryItem *FileClickHandler::getActionItem() const {
|
||||
return Auth().data().message(context());
|
||||
return _session->data().message(context());
|
||||
}
|
||||
|
||||
PeerId PeerFromMessage(const MTPmessage &message) {
|
||||
|
|
|
@ -10,28 +10,32 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "base/value_ordering.h"
|
||||
#include "ui/text/text.h" // For QFIXED_MAX
|
||||
|
||||
class HistoryItem;
|
||||
using HistoryItemsList = std::vector<not_null<HistoryItem*>>;
|
||||
|
||||
class StorageImageLocation;
|
||||
class WebFileLocation;
|
||||
struct GeoPointLocation;
|
||||
|
||||
namespace Storage {
|
||||
namespace Cache {
|
||||
struct Key;
|
||||
} // namespace Cache
|
||||
} // namespace Storage
|
||||
|
||||
class HistoryItem;
|
||||
using HistoryItemsList = std::vector<not_null<HistoryItem*>>;
|
||||
|
||||
namespace Ui {
|
||||
class InputField;
|
||||
} // namespace Ui
|
||||
|
||||
namespace Main {
|
||||
class Session;
|
||||
} // namespace Main
|
||||
|
||||
namespace Images {
|
||||
enum class Option;
|
||||
using Options = base::flags<Option>;
|
||||
} // namespace Images
|
||||
|
||||
class StorageImageLocation;
|
||||
class WebFileLocation;
|
||||
struct GeoPointLocation;
|
||||
|
||||
namespace Data {
|
||||
|
||||
struct UploadState {
|
||||
|
@ -449,7 +453,15 @@ struct SendAction {
|
|||
|
||||
class FileClickHandler : public LeftButtonClickHandler {
|
||||
public:
|
||||
FileClickHandler(FullMsgId context) : _context(context) {
|
||||
FileClickHandler(
|
||||
not_null<Main::Session*> session,
|
||||
FullMsgId context)
|
||||
: _session(session)
|
||||
, _context(context) {
|
||||
}
|
||||
|
||||
[[nodiscard]] Main::Session &session() const {
|
||||
return *_session;
|
||||
}
|
||||
|
||||
void setMessageId(FullMsgId context) {
|
||||
|
@ -464,6 +476,7 @@ protected:
|
|||
HistoryItem *getActionItem() const;
|
||||
|
||||
private:
|
||||
const not_null<Main::Session*> _session;
|
||||
FullMsgId _context;
|
||||
|
||||
};
|
||||
|
|
|
@ -1539,6 +1539,7 @@ void HistoryInner::showContextMenu(QContextMenuEvent *e, bool showFromTouch) {
|
|||
}
|
||||
|
||||
_menu = base::make_unique_q<Ui::PopupMenu>(this);
|
||||
const auto session = &this->session();
|
||||
|
||||
const auto addItemActions = [&](HistoryItem *item) {
|
||||
if (!item
|
||||
|
@ -1578,7 +1579,7 @@ void HistoryInner::showContextMenu(QContextMenuEvent *e, bool showFromTouch) {
|
|||
});
|
||||
if (photo->hasSticker) {
|
||||
_menu->addAction(tr::lng_context_attached_stickers(tr::now), [=] {
|
||||
session().api().requestAttachedStickerSets(photo);
|
||||
session->api().requestAttachedStickerSets(photo);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
@ -1599,7 +1600,7 @@ void HistoryInner::showContextMenu(QContextMenuEvent *e, bool showFromTouch) {
|
|||
return item
|
||||
&& document->isGifv()
|
||||
&& !Data::AutoDownload::ShouldAutoPlay(
|
||||
document->session().settings().autoDownload(),
|
||||
session->settings().autoDownload(),
|
||||
item->history()->peer,
|
||||
document);
|
||||
}();
|
||||
|
@ -1642,7 +1643,7 @@ void HistoryInner::showContextMenu(QContextMenuEvent *e, bool showFromTouch) {
|
|||
}
|
||||
if (item && item->hasDirectLink() && isUponSelected != 2 && isUponSelected != -2) {
|
||||
_menu->addAction(item->history()->peer->isMegagroup() ? tr::lng_context_copy_link(tr::now) : tr::lng_context_copy_post_link(tr::now), [=] {
|
||||
HistoryView::CopyPostLink(itemId);
|
||||
HistoryView::CopyPostLink(session, itemId);
|
||||
});
|
||||
}
|
||||
if (isUponSelected > 1) {
|
||||
|
@ -1680,7 +1681,7 @@ void HistoryInner::showContextMenu(QContextMenuEvent *e, bool showFromTouch) {
|
|||
}
|
||||
if (IsServerMsgId(item->id) && !item->serviceMsg()) {
|
||||
_menu->addAction(tr::lng_context_select_msg(tr::now), [=] {
|
||||
if (const auto item = session().data().message(itemId)) {
|
||||
if (const auto item = session->data().message(itemId)) {
|
||||
if (const auto view = item->mainView()) {
|
||||
changeSelection(&_selected, item, SelectAction::Select);
|
||||
repaintItem(item);
|
||||
|
@ -1697,7 +1698,7 @@ void HistoryInner::showContextMenu(QContextMenuEvent *e, bool showFromTouch) {
|
|||
: App::hoveredLinkItem()
|
||||
? App::hoveredLinkItem()->data().get()
|
||||
: nullptr) {
|
||||
if (const auto group = session().data().groups().find(result)) {
|
||||
if (const auto group = session->data().groups().find(result)) {
|
||||
return group->items.front();
|
||||
}
|
||||
return result;
|
||||
|
@ -1731,11 +1732,11 @@ void HistoryInner::showContextMenu(QContextMenuEvent *e, bool showFromTouch) {
|
|||
_menu->addAction(document->isStickerSetInstalled() ? tr::lng_context_pack_info(tr::now) : tr::lng_context_pack_add(tr::now), [=] {
|
||||
showStickerPackInfo(document);
|
||||
});
|
||||
_menu->addAction(session().data().stickers().isFaved(document) ? tr::lng_faved_stickers_remove(tr::now) : tr::lng_faved_stickers_add(tr::now), [=] {
|
||||
session().api().toggleFavedSticker(
|
||||
_menu->addAction(session->data().stickers().isFaved(document) ? tr::lng_faved_stickers_remove(tr::now) : tr::lng_faved_stickers_add(tr::now), [=] {
|
||||
session->api().toggleFavedSticker(
|
||||
document,
|
||||
itemId,
|
||||
!session().data().stickers().isFaved(document));
|
||||
!session->data().stickers().isFaved(document));
|
||||
});
|
||||
}
|
||||
_menu->addAction(tr::lng_context_save_image(tr::now), App::LambdaDelayed(st::defaultDropdownMenu.menu.ripple.hideDuration, this, [=] {
|
||||
|
@ -1748,12 +1749,12 @@ void HistoryInner::showContextMenu(QContextMenuEvent *e, bool showFromTouch) {
|
|||
if (!poll->closed()) {
|
||||
if (poll->voted() && !poll->quiz()) {
|
||||
_menu->addAction(tr::lng_polls_retract(tr::now), [=] {
|
||||
session().api().sendPollVotes(itemId, {});
|
||||
session->api().sendPollVotes(itemId, {});
|
||||
});
|
||||
}
|
||||
if (item->canStopPoll()) {
|
||||
_menu->addAction(tr::lng_polls_stop(tr::now), [=] {
|
||||
HistoryView::StopPoll(itemId);
|
||||
HistoryView::StopPoll(session, itemId);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -1783,7 +1784,7 @@ void HistoryInner::showContextMenu(QContextMenuEvent *e, bool showFromTouch) {
|
|||
});
|
||||
} else if (item && item->hasDirectLink() && isUponSelected != 2 && isUponSelected != -2) {
|
||||
_menu->addAction(item->history()->peer->isMegagroup() ? tr::lng_context_copy_link(tr::now) : tr::lng_context_copy_post_link(tr::now), [=] {
|
||||
HistoryView::CopyPostLink(itemId);
|
||||
HistoryView::CopyPostLink(session, itemId);
|
||||
});
|
||||
}
|
||||
if (isUponSelected > 1) {
|
||||
|
@ -1820,7 +1821,7 @@ void HistoryInner::showContextMenu(QContextMenuEvent *e, bool showFromTouch) {
|
|||
}
|
||||
if (item->id > 0 && !item->serviceMsg()) {
|
||||
_menu->addAction(tr::lng_context_select_msg(tr::now), [=] {
|
||||
if (const auto item = session().data().message(itemId)) {
|
||||
if (const auto item = session->data().message(itemId)) {
|
||||
if (const auto view = item->mainView()) {
|
||||
changeSelectionAsGroup(&_selected, item, SelectAction::Select);
|
||||
repaintItem(view);
|
||||
|
@ -1835,7 +1836,7 @@ void HistoryInner::showContextMenu(QContextMenuEvent *e, bool showFromTouch) {
|
|||
&& !App::mousedItem()->data()->serviceMsg()) {
|
||||
const auto itemId = App::mousedItem()->data()->fullId();
|
||||
_menu->addAction(tr::lng_context_select_msg(tr::now), [=] {
|
||||
if (const auto item = session().data().message(itemId)) {
|
||||
if (const auto item = session->data().message(itemId)) {
|
||||
if (const auto view = item->mainView()) {
|
||||
changeSelectionAsGroup(&_selected, item, SelectAction::Select);
|
||||
repaintItem(item);
|
||||
|
|
|
@ -389,10 +389,12 @@ void HistoryMessageReply::refreshReplyToDocument() {
|
|||
}
|
||||
|
||||
ReplyMarkupClickHandler::ReplyMarkupClickHandler(
|
||||
not_null<Data::Session*> owner,
|
||||
int row,
|
||||
int column,
|
||||
FullMsgId context)
|
||||
: _itemId(context)
|
||||
: _owner(owner)
|
||||
, _itemId(context)
|
||||
, _row(row)
|
||||
, _column(column) {
|
||||
}
|
||||
|
@ -423,15 +425,11 @@ QString ReplyMarkupClickHandler::copyToClipboardContextItemText() const {
|
|||
// Note: it is possible that we will point to the different button
|
||||
// than the one was used when constructing the handler, but not a big deal.
|
||||
const HistoryMessageMarkupButton *ReplyMarkupClickHandler::getButton() const {
|
||||
return HistoryMessageMarkupButton::Get(
|
||||
&Auth().data(),
|
||||
_itemId,
|
||||
_row,
|
||||
_column);
|
||||
return HistoryMessageMarkupButton::Get(_owner, _itemId, _row, _column);
|
||||
}
|
||||
|
||||
void ReplyMarkupClickHandler::onClickImpl() const {
|
||||
if (const auto item = Auth().data().message(_itemId)) {
|
||||
if (const auto item = _owner->message(_itemId)) {
|
||||
App::activateBotCommand(item, _row, _column);
|
||||
}
|
||||
}
|
||||
|
@ -459,6 +457,7 @@ ReplyKeyboard::ReplyKeyboard(
|
|||
})
|
||||
, _st(std::move(s)) {
|
||||
if (const auto markup = _item->Get<HistoryMessageReplyMarkup>()) {
|
||||
const auto owner = &_item->history()->owner();
|
||||
const auto context = _item->fullId();
|
||||
const auto rowCount = int(markup->rows.size());
|
||||
_rows.reserve(rowCount);
|
||||
|
@ -472,6 +471,7 @@ ReplyKeyboard::ReplyKeyboard(
|
|||
const auto text = row[j].text;
|
||||
button.type = row.at(j).type;
|
||||
button.link = std::make_shared<ReplyMarkupClickHandler>(
|
||||
owner,
|
||||
i,
|
||||
j,
|
||||
context);
|
||||
|
|
|
@ -223,7 +223,11 @@ private:
|
|||
|
||||
class ReplyMarkupClickHandler : public LeftButtonClickHandler {
|
||||
public:
|
||||
ReplyMarkupClickHandler(int row, int column, FullMsgId context);
|
||||
ReplyMarkupClickHandler(
|
||||
not_null<Data::Session*> owner,
|
||||
int row,
|
||||
int column,
|
||||
FullMsgId context);
|
||||
|
||||
QString tooltip() const override {
|
||||
return _fullDisplayed ? QString() : buttonText();
|
||||
|
@ -253,6 +257,7 @@ protected:
|
|||
void onClickImpl() const override;
|
||||
|
||||
private:
|
||||
const not_null<Data::Session*> _owner;
|
||||
FullMsgId _itemId;
|
||||
int _row = 0;
|
||||
int _column = 0;
|
||||
|
|
|
@ -28,6 +28,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "ui/text/text_isolated_emoji.h"
|
||||
#include "ui/text_options.h"
|
||||
#include "core/application.h"
|
||||
#include "core/ui_integration.h"
|
||||
#include "layout.h"
|
||||
#include "window/notifications_manager.h"
|
||||
#include "window/window_session_controller.h"
|
||||
|
@ -219,7 +220,9 @@ void FastShareMessage(not_null<HistoryItem*> item) {
|
|||
auto copyCallback = [=]() {
|
||||
if (const auto item = owner->message(data->msgIds[0])) {
|
||||
if (item->hasDirectLink()) {
|
||||
HistoryView::CopyPostLink(item->fullId());
|
||||
HistoryView::CopyPostLink(
|
||||
&item->history()->session(),
|
||||
item->fullId());
|
||||
} else if (const auto bot = item->getMessageBot()) {
|
||||
if (const auto media = item->media()) {
|
||||
if (const auto game = media->game()) {
|
||||
|
@ -1206,7 +1209,7 @@ TextWithEntities HistoryMessage::withLocalEntities(
|
|||
}
|
||||
|
||||
void HistoryMessage::setText(const TextWithEntities &textWithEntities) {
|
||||
for_const (auto &entity, textWithEntities.entities) {
|
||||
for (const auto &entity : textWithEntities.entities) {
|
||||
auto type = entity.type();
|
||||
if (type == EntityType::Url
|
||||
|| type == EntityType::CustomUrl
|
||||
|
@ -1220,11 +1223,16 @@ void HistoryMessage::setText(const TextWithEntities &textWithEntities) {
|
|||
setEmptyText();
|
||||
return;
|
||||
}
|
||||
|
||||
clearIsolatedEmoji();
|
||||
const auto context = Core::UiIntegration::Context{
|
||||
.session = &history()->session()
|
||||
};
|
||||
_text.setMarkedText(
|
||||
st::messageTextStyle,
|
||||
withLocalEntities(textWithEntities),
|
||||
Ui::ItemTextOptions(this));
|
||||
Ui::ItemTextOptions(this),
|
||||
context);
|
||||
if (!textWithEntities.text.isEmpty() && _text.isEmpty()) {
|
||||
// If server has allowed some text that we've trim-ed entirely,
|
||||
// just replace it with something so that UI won't look buggy.
|
||||
|
@ -1235,6 +1243,7 @@ void HistoryMessage::setText(const TextWithEntities &textWithEntities) {
|
|||
} else if (!_media) {
|
||||
checkIsolatedEmoji();
|
||||
}
|
||||
|
||||
_textWidth = -1;
|
||||
_textHeight = 0;
|
||||
}
|
||||
|
|
|
@ -407,7 +407,7 @@ HistoryService::PreparedText HistoryService::prepareGameScoreText() {
|
|||
auto result = PreparedText {};
|
||||
auto gamescore = Get<HistoryServiceGameScore>();
|
||||
|
||||
auto computeGameTitle = [gamescore, &result]() -> QString {
|
||||
auto computeGameTitle = [&]() -> QString {
|
||||
if (gamescore && gamescore->msg) {
|
||||
if (const auto media = gamescore->msg->media()) {
|
||||
if (const auto game = media->game()) {
|
||||
|
@ -415,6 +415,7 @@ HistoryService::PreparedText HistoryService::prepareGameScoreText() {
|
|||
const auto column = 0;
|
||||
result.links.push_back(
|
||||
std::make_shared<ReplyMarkupClickHandler>(
|
||||
&history()->owner(),
|
||||
row,
|
||||
column,
|
||||
gamescore->msg->fullId()));
|
||||
|
|
|
@ -128,8 +128,8 @@ void AddPhotoActions(
|
|||
});
|
||||
}
|
||||
|
||||
void OpenGif(FullMsgId itemId) {
|
||||
if (const auto item = Auth().data().message(itemId)) {
|
||||
void OpenGif(not_null<Main::Session*> session, FullMsgId itemId) {
|
||||
if (const auto item = session->data().message(itemId)) {
|
||||
if (const auto media = item->media()) {
|
||||
if (const auto document = media->document()) {
|
||||
Core::App().showDocument(document, item);
|
||||
|
@ -182,7 +182,8 @@ void AddDocumentActions(
|
|||
});
|
||||
return;
|
||||
}
|
||||
if (const auto item = document->session().data().message(contextId)) {
|
||||
const auto session = &document->session();
|
||||
if (const auto item = session->data().message(contextId)) {
|
||||
const auto notAutoplayedGif = [&] {
|
||||
return document->isGifv()
|
||||
&& !Data::AutoDownload::ShouldAutoPlay(
|
||||
|
@ -192,7 +193,7 @@ void AddDocumentActions(
|
|||
}();
|
||||
if (notAutoplayedGif) {
|
||||
menu->addAction(tr::lng_context_open_gif(tr::now), [=] {
|
||||
OpenGif(contextId);
|
||||
OpenGif(session, contextId);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -231,12 +232,13 @@ void AddPostLinkAction(
|
|||
&& !request.link->copyToClipboardContextItemText().isEmpty()) {
|
||||
return;
|
||||
}
|
||||
const auto session = &item->history()->session();
|
||||
const auto itemId = item->fullId();
|
||||
menu->addAction(
|
||||
(item->history()->peer->isMegagroup()
|
||||
? tr::lng_context_copy_link
|
||||
: tr::lng_context_copy_post_link)(tr::now),
|
||||
[=] { CopyPostLink(itemId); });
|
||||
[=] { CopyPostLink(session, itemId); });
|
||||
}
|
||||
|
||||
MessageIdsList ExtractIdsList(const SelectedItems &items) {
|
||||
|
@ -698,8 +700,8 @@ base::unique_qptr<Ui::PopupMenu> FillContextMenu(
|
|||
return result;
|
||||
}
|
||||
|
||||
void CopyPostLink(FullMsgId itemId) {
|
||||
const auto item = Auth().data().message(itemId);
|
||||
void CopyPostLink(not_null<Main::Session*> session, FullMsgId itemId) {
|
||||
const auto item = session->data().message(itemId);
|
||||
if (!item || !item->hasDirectLink()) {
|
||||
return;
|
||||
}
|
||||
|
@ -714,11 +716,11 @@ void CopyPostLink(FullMsgId itemId) {
|
|||
: tr::lng_context_about_private_link(tr::now));
|
||||
}
|
||||
|
||||
void StopPoll(FullMsgId itemId) {
|
||||
void StopPoll(not_null<Main::Session*> session, FullMsgId itemId) {
|
||||
const auto stop = [=] {
|
||||
Ui::hideLayer();
|
||||
if (const auto item = Auth().data().message(itemId)) {
|
||||
item->history()->session().api().closePoll(item);
|
||||
if (const auto item = session->data().message(itemId)) {
|
||||
session->api().closePoll(item);
|
||||
}
|
||||
};
|
||||
Ui::show(Box<ConfirmBox>(
|
||||
|
|
|
@ -43,7 +43,7 @@ base::unique_qptr<Ui::PopupMenu> FillContextMenu(
|
|||
not_null<ListWidget*> list,
|
||||
const ContextMenuRequest &request);
|
||||
|
||||
void CopyPostLink(FullMsgId itemId);
|
||||
void StopPoll(FullMsgId itemId);
|
||||
void CopyPostLink(not_null<Main::Session*> session, FullMsgId itemId);
|
||||
void StopPoll(not_null<Main::Session*> session, FullMsgId itemId);
|
||||
|
||||
} // namespace
|
||||
|
|
|
@ -48,6 +48,7 @@ QSize Game::countOptimalSize() {
|
|||
const auto row = 0;
|
||||
const auto column = 0;
|
||||
_openl = std::make_shared<ReplyMarkupClickHandler>(
|
||||
&item->history()->owner(),
|
||||
row,
|
||||
column,
|
||||
item->fullId());
|
||||
|
|
|
@ -126,14 +126,17 @@ void Gif::setPosition(int32 position) {
|
|||
}
|
||||
|
||||
void DeleteSavedGifClickHandler::onClickImpl() const {
|
||||
Auth().api().toggleSavedGif(_data, Data::FileOriginSavedGifs(), false);
|
||||
_data->session().api().toggleSavedGif(
|
||||
_data,
|
||||
Data::FileOriginSavedGifs(),
|
||||
false);
|
||||
|
||||
const auto index = Auth().data().stickers().savedGifs().indexOf(_data);
|
||||
const auto index = _data->owner().stickers().savedGifs().indexOf(_data);
|
||||
if (index >= 0) {
|
||||
Auth().data().stickers().savedGifsRef().remove(index);
|
||||
_data->owner().stickers().savedGifsRef().remove(index);
|
||||
Local::writeSavedGifs();
|
||||
}
|
||||
Auth().data().stickers().notifySavedGifsUpdated();
|
||||
_data->owner().stickers().notifySavedGifsUpdated();
|
||||
}
|
||||
|
||||
int Gif::resizeGetHeight(int width) {
|
||||
|
|
|
@ -45,14 +45,14 @@ protected:
|
|||
|
||||
class DeleteSavedGifClickHandler : public LeftButtonClickHandler {
|
||||
public:
|
||||
DeleteSavedGifClickHandler(DocumentData *data) : _data(data) {
|
||||
DeleteSavedGifClickHandler(not_null<DocumentData*> data) : _data(data) {
|
||||
}
|
||||
|
||||
protected:
|
||||
void onClickImpl() const override;
|
||||
|
||||
private:
|
||||
DocumentData *_data;
|
||||
const not_null<DocumentData*> _data;
|
||||
|
||||
};
|
||||
|
||||
|
|
|
@ -91,6 +91,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include <unordered_set>
|
||||
#include <algorithm>
|
||||
#include <memory>
|
||||
#include <any>
|
||||
#include <optional>
|
||||
|
||||
#include <range/v3/all.hpp>
|
||||
|
|
Loading…
Add table
Reference in a new issue