mirror of
https://github.com/telegramdesktop/tdesktop
synced 2025-02-23 08:46:55 +00:00
parent
3fd772ce17
commit
6c56fad180
@ -62,15 +62,15 @@ DocumentClickHandler::DocumentClickHandler(
|
||||
|
||||
DocumentOpenClickHandler::DocumentOpenClickHandler(
|
||||
not_null<DocumentData*> document,
|
||||
Fn<void()> &&callback)
|
||||
: DocumentClickHandler(document)
|
||||
Fn<void(FullMsgId)> &&callback,
|
||||
FullMsgId context)
|
||||
: DocumentClickHandler(document, context)
|
||||
, _handler(std::move(callback)) {
|
||||
Expects(_handler != nullptr);
|
||||
}
|
||||
|
||||
void DocumentOpenClickHandler::onClickImpl() const {
|
||||
if (_handler) {
|
||||
_handler();
|
||||
}
|
||||
_handler(context());
|
||||
}
|
||||
|
||||
void DocumentSaveClickHandler::Save(
|
||||
@ -170,15 +170,15 @@ PeerData *PhotoClickHandler::peer() const {
|
||||
|
||||
PhotoOpenClickHandler::PhotoOpenClickHandler(
|
||||
not_null<PhotoData*> photo,
|
||||
Fn<void()> &&callback)
|
||||
: PhotoClickHandler(photo)
|
||||
Fn<void(FullMsgId)> &&callback,
|
||||
FullMsgId context)
|
||||
: PhotoClickHandler(photo, context)
|
||||
, _handler(std::move(callback)) {
|
||||
Expects(_handler != nullptr);
|
||||
}
|
||||
|
||||
void PhotoOpenClickHandler::onClickImpl() const {
|
||||
if (_handler) {
|
||||
_handler();
|
||||
}
|
||||
_handler(context());
|
||||
}
|
||||
|
||||
void PhotoSaveClickHandler::onClickImpl() const {
|
||||
|
@ -74,13 +74,14 @@ class DocumentOpenClickHandler : public DocumentClickHandler {
|
||||
public:
|
||||
DocumentOpenClickHandler(
|
||||
not_null<DocumentData*> document,
|
||||
Fn<void()> &&callback);
|
||||
Fn<void(FullMsgId)> &&callback,
|
||||
FullMsgId context = FullMsgId());
|
||||
|
||||
protected:
|
||||
void onClickImpl() const override;
|
||||
|
||||
private:
|
||||
Fn<void()> _handler;
|
||||
const Fn<void(FullMsgId)> _handler;
|
||||
|
||||
};
|
||||
|
||||
@ -148,13 +149,16 @@ private:
|
||||
|
||||
class PhotoOpenClickHandler : public PhotoClickHandler {
|
||||
public:
|
||||
PhotoOpenClickHandler(not_null<PhotoData*> photo, Fn<void()> &&callback);
|
||||
PhotoOpenClickHandler(
|
||||
not_null<PhotoData*> photo,
|
||||
Fn<void(FullMsgId)> &&callback,
|
||||
FullMsgId context = FullMsgId());
|
||||
|
||||
protected:
|
||||
void onClickImpl() const override;
|
||||
|
||||
private:
|
||||
Fn<void()> _handler;
|
||||
const Fn<void(FullMsgId)> _handler;
|
||||
|
||||
};
|
||||
|
||||
|
@ -221,7 +221,9 @@ void Document::createComponents(bool caption) {
|
||||
_realParent->fullId());
|
||||
}
|
||||
if (const auto voice = Get<HistoryDocumentVoice>()) {
|
||||
voice->_seekl = std::make_shared<VoiceSeekClickHandler>(_data, [] {});
|
||||
voice->_seekl = std::make_shared<VoiceSeekClickHandler>(
|
||||
_data,
|
||||
[](FullMsgId) {});
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -48,7 +48,7 @@ void File::clickHandlerPressedChanged(
|
||||
}
|
||||
|
||||
void File::setLinks(
|
||||
ClickHandlerPtr &&openl,
|
||||
FileClickHandlerPtr &&openl,
|
||||
FileClickHandlerPtr &&savel,
|
||||
FileClickHandlerPtr &&cancell) {
|
||||
_openl = std::move(openl);
|
||||
@ -58,6 +58,7 @@ void File::setLinks(
|
||||
|
||||
void File::refreshParentId(not_null<HistoryItem*> realParent) {
|
||||
const auto contextId = realParent->fullId();
|
||||
_openl->setMessageId(contextId);
|
||||
_savel->setMessageId(contextId);
|
||||
_cancell->setMessageId(contextId);
|
||||
}
|
||||
@ -114,9 +115,10 @@ void File::setDocumentLinks(
|
||||
setLinks(
|
||||
std::make_shared<DocumentOpenClickHandler>(
|
||||
document,
|
||||
crl::guard(this, [=] {
|
||||
_parent->delegate()->elementOpenDocument(document, context);
|
||||
})),
|
||||
crl::guard(this, [=](FullMsgId id) {
|
||||
_parent->delegate()->elementOpenDocument(document, id);
|
||||
}),
|
||||
context),
|
||||
std::make_shared<DocumentSaveClickHandler>(document, context),
|
||||
std::make_shared<DocumentCancelClickHandler>(document, context));
|
||||
}
|
||||
|
@ -44,11 +44,10 @@ protected:
|
||||
using FileClickHandlerPtr = std::shared_ptr<FileClickHandler>;
|
||||
|
||||
not_null<HistoryItem*> _realParent;
|
||||
ClickHandlerPtr _openl;
|
||||
FileClickHandlerPtr _savel, _cancell;
|
||||
FileClickHandlerPtr _openl, _savel, _cancell;
|
||||
|
||||
void setLinks(
|
||||
ClickHandlerPtr &&openl,
|
||||
FileClickHandlerPtr &&openl,
|
||||
FileClickHandlerPtr &&savel,
|
||||
FileClickHandlerPtr &&cancell);
|
||||
void setDocumentLinks(
|
||||
|
@ -87,9 +87,10 @@ Photo::~Photo() {
|
||||
|
||||
void Photo::create(FullMsgId contextId, PeerData *chat) {
|
||||
setLinks(
|
||||
std::make_shared<PhotoOpenClickHandler>(_data, crl::guard(this, [=] {
|
||||
showPhoto();
|
||||
})),
|
||||
std::make_shared<PhotoOpenClickHandler>(
|
||||
_data,
|
||||
crl::guard(this, [=](FullMsgId id) { showPhoto(id); }),
|
||||
contextId),
|
||||
std::make_shared<PhotoSaveClickHandler>(_data, contextId, chat),
|
||||
std::make_shared<PhotoCancelClickHandler>(_data, contextId, chat));
|
||||
if ((_dataMedia = _data->activeMediaView())) {
|
||||
@ -774,7 +775,7 @@ void Photo::playAnimation(bool autoplay) {
|
||||
if (_streamed && autoplay) {
|
||||
return;
|
||||
} else if (_streamed && videoAutoplayEnabled()) {
|
||||
showPhoto();
|
||||
showPhoto(_parent->data()->fullId());
|
||||
return;
|
||||
}
|
||||
if (_streamed) {
|
||||
@ -847,10 +848,8 @@ void Photo::parentTextUpdated() {
|
||||
history()->owner().requestViewResize(_parent);
|
||||
}
|
||||
|
||||
void Photo::showPhoto() {
|
||||
_parent->delegate()->elementOpenPhoto(
|
||||
_data,
|
||||
_parent->data()->fullId());
|
||||
void Photo::showPhoto(FullMsgId id) {
|
||||
_parent->delegate()->elementOpenPhoto(_data, id);
|
||||
}
|
||||
|
||||
} // namespace HistoryView
|
||||
|
@ -102,7 +102,7 @@ protected:
|
||||
private:
|
||||
struct Streamed;
|
||||
|
||||
void showPhoto();
|
||||
void showPhoto(FullMsgId id);
|
||||
|
||||
void create(FullMsgId contextId, PeerData *chat = nullptr);
|
||||
|
||||
|
@ -287,11 +287,10 @@ void Sticker::refreshLink() {
|
||||
// .webp image and we allow to open it in media viewer.
|
||||
_link = std::make_shared<DocumentOpenClickHandler>(
|
||||
_data,
|
||||
crl::guard(this, [=] {
|
||||
_parent->delegate()->elementOpenDocument(
|
||||
_data,
|
||||
_parent->data()->fullId());
|
||||
}));
|
||||
crl::guard(this, [=](FullMsgId id) {
|
||||
_parent->delegate()->elementOpenDocument(_data, id);
|
||||
}),
|
||||
_parent->data()->fullId());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2276,9 +2276,7 @@ void OverlayWidget::show(OpenRequest request) {
|
||||
}
|
||||
|
||||
clearControlsState();
|
||||
if (contextPeer) {
|
||||
_firstOpenedPeerPhoto = true;
|
||||
}
|
||||
_firstOpenedPeerPhoto = (contextPeer != nullptr);
|
||||
assignMediaPointer(photo);
|
||||
|
||||
displayPhoto(photo, contextPeer ? nullptr : contextItem);
|
||||
|
@ -188,9 +188,10 @@ void RadialProgressItem::setDocumentLinks(
|
||||
setLinks(
|
||||
std::make_shared<DocumentOpenClickHandler>(
|
||||
document,
|
||||
crl::guard(this, [=] {
|
||||
delegate()->openDocument(document, context);
|
||||
})),
|
||||
crl::guard(this, [=](FullMsgId id) {
|
||||
delegate()->openDocument(document, id);
|
||||
}),
|
||||
context),
|
||||
std::make_shared<DocumentSaveClickHandler>(document, context),
|
||||
std::make_shared<DocumentCancelClickHandler>(document, context));
|
||||
}
|
||||
@ -277,9 +278,10 @@ Photo::Photo(
|
||||
not_null<PhotoData*> photo)
|
||||
: ItemBase(delegate, parent)
|
||||
, _data(photo)
|
||||
, _link(std::make_shared<PhotoOpenClickHandler>(photo, crl::guard(this, [=] {
|
||||
delegate->openPhoto(photo, parent->fullId());
|
||||
}))) {
|
||||
, _link(std::make_shared<PhotoOpenClickHandler>(
|
||||
photo,
|
||||
crl::guard(this, [=](FullMsgId id) { delegate->openPhoto(photo, id); }),
|
||||
parent->fullId())) {
|
||||
if (_data->inlineThumbnailBytes().isEmpty()
|
||||
&& (_data->hasExact(Data::PhotoSize::Small)
|
||||
|| _data->hasExact(Data::PhotoSize::Thumbnail))) {
|
||||
@ -602,9 +604,10 @@ Voice::Voice(
|
||||
, _data(voice)
|
||||
, _namel(std::make_shared<DocumentOpenClickHandler>(
|
||||
_data,
|
||||
crl::guard(this, [=] {
|
||||
delegate->openDocument(_data, parent->fullId());
|
||||
})))
|
||||
crl::guard(this, [=](FullMsgId id) {
|
||||
delegate->openDocument(_data, id);
|
||||
}),
|
||||
parent->fullId()))
|
||||
, _st(st) {
|
||||
AddComponents(Info::Bit());
|
||||
|
||||
@ -913,9 +916,10 @@ Document::Document(
|
||||
, _msgl(goToMessageClickHandler(parent))
|
||||
, _namel(std::make_shared<DocumentOpenClickHandler>(
|
||||
_data,
|
||||
crl::guard(this, [=] {
|
||||
delegate->openDocument(_data, parent->fullId());
|
||||
})))
|
||||
crl::guard(this, [=](FullMsgId id) {
|
||||
delegate->openDocument(_data, id);
|
||||
}),
|
||||
parent->fullId()))
|
||||
, _st(st)
|
||||
, _date(langDateTime(base::unixtime::parse(_data->date)))
|
||||
, _datew(st::normalFont->width(_date))
|
||||
@ -1469,9 +1473,10 @@ Link::Link(
|
||||
if (_page->document) {
|
||||
_photol = std::make_shared<DocumentOpenClickHandler>(
|
||||
_page->document,
|
||||
crl::guard(this, [=] {
|
||||
delegate->openDocument(_page->document, parent->fullId());
|
||||
}));
|
||||
crl::guard(this, [=](FullMsgId id) {
|
||||
delegate->openDocument(_page->document, id);
|
||||
}),
|
||||
parent->fullId());
|
||||
} else if (_page->photo) {
|
||||
if (_page->type == WebPageType::Profile || _page->type == WebPageType::Video) {
|
||||
_photol = createHandler(_page->url);
|
||||
@ -1480,9 +1485,10 @@ Link::Link(
|
||||
|| _page->siteName == qstr("Facebook")) {
|
||||
_photol = std::make_shared<PhotoOpenClickHandler>(
|
||||
_page->photo,
|
||||
crl::guard(this, [=] {
|
||||
delegate->openPhoto(_page->photo, parent->fullId());
|
||||
}));
|
||||
crl::guard(this, [=](FullMsgId id) {
|
||||
delegate->openPhoto(_page->photo, id);
|
||||
}),
|
||||
parent->fullId());
|
||||
} else {
|
||||
_photol = createHandler(_page->url);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user