From a425024f21fa39ecb6cdeaf88b51ee7d349f21ea Mon Sep 17 00:00:00 2001 From: 23rd <23rd@vivaldi.net> Date: Sat, 12 Jun 2021 02:04:16 +0300 Subject: [PATCH] Fixed userpic updating of pinned peers in touchbar. --- .../mac/touchbar/items/mac_pinned_chats_item.mm | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/Telegram/SourceFiles/platform/mac/touchbar/items/mac_pinned_chats_item.mm b/Telegram/SourceFiles/platform/mac/touchbar/items/mac_pinned_chats_item.mm index 85e48229c1..e2ab74355f 100644 --- a/Telegram/SourceFiles/platform/mac/touchbar/items/mac_pinned_chats_item.mm +++ b/Telegram/SourceFiles/platform/mac/touchbar/items/mac_pinned_chats_item.mm @@ -441,7 +441,8 @@ TimeId CalculateOnlineTill(not_null peer) { _gestures.events( ) | rpl::filter([=] { return !(*waitForFinish); - }) | rpl::start_with_next([=](not_null gesture) { + }) | rpl::start_with_next([=]( + not_null gesture) { const auto currentPosition = [gesture locationInView:self].x; switch ([gesture state]) { @@ -530,7 +531,8 @@ TimeId CalculateOnlineTill(not_null peer) { pin->peer->paintUserpic(p, pin->userpicView, 0, 0, userpic.width()); userpic.setDevicePixelRatio(cRetinaFactor()); pin->userpic = std::move(userpic); - [self setNeedsDisplayInRect:PeerRectByIndex(pin->index)]; + const auto userpicIndex = pin->index + [self shift]; + [self setNeedsDisplayInRect:PeerRectByIndex(userpicIndex)]; }; const auto updateUserpics = [=] { ranges::for_each(_pins, singleUserpic); @@ -653,12 +655,15 @@ TimeId CalculateOnlineTill(not_null peer) { peerChangedLifetime->destroy(); for (const auto &pin : _pins) { const auto peer = pin->peer; + const auto index = pin->index; + _session->changes().peerUpdates( peer, UpdateFlag::Photo - ) | rpl::start_with_next( - listenToDownloaderFinished, - *peerChangedLifetime); + ) | rpl::start_with_next([=](const Data::PeerUpdate &update) { + _pins[index]->userpicView = update.peer->createUserpicView(); + listenToDownloaderFinished(); + }, *peerChangedLifetime); if (const auto user = peer->asUser()) { if (!user->isServiceUser() @@ -668,7 +673,6 @@ TimeId CalculateOnlineTill(not_null peer) { } } - const auto index = pin->index; rpl::merge( _session->changes().historyUpdates( _session->data().history(peer),