mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-07 23:53:58 +02:00
Show message from Replies bot inside thread.
This commit is contained in:
parent
8f4fdb6d0d
commit
433c147dd0
1 changed files with 33 additions and 1 deletions
|
@ -27,6 +27,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "mainwindow.h"
|
#include "mainwindow.h"
|
||||||
#include "main/main_session.h"
|
#include "main/main_session.h"
|
||||||
#include "window/window_session_controller.h"
|
#include "window/window_session_controller.h"
|
||||||
|
#include "apiwrap.h"
|
||||||
#include "layout.h"
|
#include "layout.h"
|
||||||
#include "facades.h"
|
#include "facades.h"
|
||||||
#include "app.h"
|
#include "app.h"
|
||||||
|
@ -2149,9 +2150,40 @@ ClickHandlerPtr Message::rightActionLink() const {
|
||||||
const auto forwarded = data()->Get<HistoryMessageForwarded>();
|
const auto forwarded = data()->Get<HistoryMessageForwarded>();
|
||||||
const auto savedFromPeer = forwarded ? forwarded->savedFromPeer : nullptr;
|
const auto savedFromPeer = forwarded ? forwarded->savedFromPeer : nullptr;
|
||||||
const auto savedFromMsgId = forwarded ? forwarded->savedFromMsgId : 0;
|
const auto savedFromMsgId = forwarded ? forwarded->savedFromMsgId : 0;
|
||||||
|
const auto showByThread = std::make_shared<FnMut<void()>>();
|
||||||
|
const auto showByThreadWeak = std::weak_ptr<FnMut<void()>>(showByThread);
|
||||||
|
if (data()->externalReply()) {
|
||||||
|
*showByThread = [=, requested = 0]() mutable {
|
||||||
|
const auto original = savedFromPeer->owner().message(savedFromPeer->asChannel(), savedFromMsgId);
|
||||||
|
if (original && original->replyToTop()) {
|
||||||
|
App::wnd()->sessionController()->showRepliesForMessage(
|
||||||
|
original->history(),
|
||||||
|
original->replyToTop(),
|
||||||
|
original->id,
|
||||||
|
Window::SectionShow::Way::Forward);
|
||||||
|
} else if (!requested) {
|
||||||
|
const auto channel = savedFromPeer->asChannel();
|
||||||
|
const auto prequested = &requested;
|
||||||
|
requested = 1;
|
||||||
|
channel->session().api().requestMessageData(channel, savedFromMsgId, [=](ChannelData *gotChannel, MsgId gotId) {
|
||||||
|
if (const auto strong = showByThreadWeak.lock()) {
|
||||||
|
*prequested = 2;
|
||||||
|
(*strong)();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else if (requested == 2) {
|
||||||
|
App::wnd()->sessionController()->showPeerHistory(
|
||||||
|
savedFromPeer,
|
||||||
|
Window::SectionShow::Way::Forward,
|
||||||
|
savedFromMsgId);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
};
|
||||||
_rightActionLink = std::make_shared<LambdaClickHandler>([=] {
|
_rightActionLink = std::make_shared<LambdaClickHandler>([=] {
|
||||||
if (const auto item = owner->message(itemId)) {
|
if (const auto item = owner->message(itemId)) {
|
||||||
if (savedFromPeer && savedFromMsgId) {
|
if (*showByThread) {
|
||||||
|
(*showByThread)();
|
||||||
|
} else if (savedFromPeer && savedFromMsgId) {
|
||||||
App::wnd()->sessionController()->showPeerHistory(
|
App::wnd()->sessionController()->showPeerHistory(
|
||||||
savedFromPeer,
|
savedFromPeer,
|
||||||
Window::SectionShow::Way::Forward,
|
Window::SectionShow::Way::Forward,
|
||||||
|
|
Loading…
Add table
Reference in a new issue