Translate pinned message as well.

This commit is contained in:
John Preston 2023-01-27 19:25:47 +04:00
parent 719466fcac
commit dc464b2718
3 changed files with 20 additions and 0 deletions

View File

@ -24,6 +24,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "history/view/history_view_context_menu.h"
#include "history/view/history_view_quick_action.h"
#include "history/view/history_view_emoji_interactions.h"
#include "history/view/history_view_pinned_bar.h"
#include "history/history_item_components.h"
#include "history/history_item_text.h"
#include "ui/chat/chat_style.h"
@ -967,6 +968,9 @@ void HistoryInner::paintEvent(QPaintEvent *e) {
auto readTill = (HistoryItem*)nullptr;
auto readContents = base::flat_set<not_null<HistoryItem*>>();
const auto guard = gsl::finally([&] {
if (const auto item = _pinnedItem.current()) {
_translateTracker->add(item, translatedTo);
}
_translateTracker->finishBunch();
if (readTill && _widget->markingMessagesRead()) {
session().data().histories().readInboxTill(readTill);
@ -3164,6 +3168,17 @@ void HistoryInner::updateSize() {
}
}
void HistoryInner::setShownPinnedId(
rpl::producer<HistoryView::PinnedId> id) {
_pinnedItem = std::move(
id
) | rpl::map([=](const HistoryView::PinnedId &id) {
return id.message
? session().data().message(id.message)
: nullptr;
});
}
void HistoryInner::enterEventHook(QEnterEvent *e) {
mouseActionUpdate(QCursor::pos());
return TWidget::enterEventHook(e);

View File

@ -32,6 +32,7 @@ enum class PointState : char;
class EmptyPainter;
class Element;
class TranslateTracker;
struct PinnedId;
} // namespace HistoryView
namespace HistoryView::Reactions {
@ -116,6 +117,7 @@ public:
void checkActivation();
void recountHistoryGeometry();
void updateSize();
void setShownPinnedId(rpl::producer<HistoryView::PinnedId> id);
void repaintItem(const HistoryItem *item);
void repaintItem(const Element *view);
@ -469,6 +471,7 @@ private:
std::unique_ptr<HistoryView::Reactions::Manager> _reactionsManager;
rpl::variable<HistoryItem*> _reactionsItem;
rpl::variable<HistoryItem*> _pinnedItem;
MouseAction _mouseAction = MouseAction::None;
TextSelectType _mouseSelectType = TextSelectType::Letters;

View File

@ -6287,6 +6287,8 @@ void HistoryWidget::setupPinnedTracker() {
Expects(_history != nullptr);
_pinnedTracker = std::make_unique<HistoryView::PinnedTracker>(_history);
_list->setShownPinnedId(_pinnedTracker->shownMessageId());
_pinnedBar = nullptr;
checkPinnedBarState();
}