Fix translation of the pinned message.

This commit is contained in:
John Preston 2023-02-01 11:43:57 +04:00
parent 514b2a55be
commit 9344e78889
3 changed files with 13 additions and 16 deletions

View file

@ -968,8 +968,8 @@ 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);
if (_pinnedItem) {
_translateTracker->add(_pinnedItem, translatedTo);
}
_translateTracker->finishBunch();
if (readTill && _widget->markingMessagesRead()) {
@ -3168,15 +3168,8 @@ 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::setShownPinned(HistoryItem *item) {
_pinnedItem = item;
}
void HistoryInner::enterEventHook(QEnterEvent *e) {

View file

@ -117,7 +117,7 @@ public:
void checkActivation();
void recountHistoryGeometry();
void updateSize();
void setShownPinnedId(rpl::producer<HistoryView::PinnedId> id);
void setShownPinned(HistoryItem *item);
void repaintItem(const HistoryItem *item);
void repaintItem(const Element *view);
@ -471,7 +471,7 @@ private:
std::unique_ptr<HistoryView::Reactions::Manager> _reactionsManager;
rpl::variable<HistoryItem*> _reactionsItem;
rpl::variable<HistoryItem*> _pinnedItem;
HistoryItem *_pinnedItem = nullptr;
MouseAction _mouseAction = MouseAction::None;
TextSelectType _mouseSelectType = TextSelectType::Letters;

View file

@ -6335,8 +6335,6 @@ void HistoryWidget::setupPinnedTracker() {
Expects(_history != nullptr);
_pinnedTracker = std::make_unique<HistoryView::PinnedTracker>(_history);
_list->setShownPinnedId(_pinnedTracker->shownMessageId());
_pinnedBar = nullptr;
checkPinnedBarState();
}
@ -6361,6 +6359,7 @@ void HistoryWidget::checkPinnedBarState() {
if (_pinnedBar) {
_pinnedBar->setContent(rpl::single(Ui::MessageBarContent()));
_pinnedTracker->reset();
_list->setShownPinned(nullptr);
_hidingPinnedBar = base::take(_pinnedBar);
const auto raw = _hidingPinnedBar.get();
base::call_delayed(st::defaultMessageBar.duration, this, [=] {
@ -6411,7 +6410,12 @@ void HistoryWidget::checkPinnedBarState() {
[bar = _pinnedBar.get()] { bar->customEmojiRepaint(); }),
std::move(pinnedRefreshed),
std::move(markupRefreshed)
) | rpl::map([](Ui::MessageBarContent &&content, bool, HistoryItem*) {
) | rpl::map([=](Ui::MessageBarContent &&content, bool, HistoryItem*) {
if (!content.title.isEmpty() || !content.text.empty()) {
_list->setShownPinned(
session().data().message(
_pinnedTracker->currentMessageId().message));
}
return std::move(content);
}));