2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-09-05 00:46:08 +00:00

Show preview in Frequent Contacts.

This commit is contained in:
John Preston
2024-05-31 15:01:43 +04:00
parent 4e8895ddd9
commit f9f51b4e41
5 changed files with 65 additions and 1 deletions

View File

@@ -10,6 +10,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "api/api_chat_participants.h"
#include "apiwrap.h"
#include "base/unixtime.h"
#include "base/qt/qt_key_modifiers.h"
#include "boxes/peer_list_box.h"
#include "data/components/recent_peers.h"
#include "data/components/top_peers.h"
@@ -940,6 +941,16 @@ void Suggestions::setupChats() {
_topPeerChosen.fire(_controller->session().data().peer(peerId));
}, _topPeers->lifetime());
_topPeers->pressed() | rpl::start_with_next([=](uint64 peerIdRaw) {
handlePressForChatPreview(PeerId(peerIdRaw), [=] {
_topPeers->cancelPress();
});
}, _topPeers->lifetime());
_topPeers->pressCancelled() | rpl::start_with_next([=] {
_controller->cancelScheduledPreview();
}, _topPeers->lifetime());
_topPeers->showMenuRequests(
) | rpl::start_with_next([=](const ShowTopPeerMenuRequest &request) {
const auto weak = Ui::MakeWeak(this);
@@ -983,6 +994,24 @@ void Suggestions::setupChats() {
_chatsScroll->setVisible(_tab.current() == Tab::Chats);
}
void Suggestions::handlePressForChatPreview(
PeerId id,
Fn<void()> cancelPress) {
const auto callback = crl::guard(this, [=](bool shown) {
if (shown) {
cancelPress();
}
});
const auto row = RowDescriptor(
_controller->session().data().history(id),
FullMsgId());
if (base::IsAltPressed()) {
_controller->showChatPreview(row, callback);
} else {
_controller->scheduleChatPreview(row, callback);
}
}
void Suggestions::setupChannels() {
_myChannelsCount.value() | rpl::start_with_next([=](int count) {
_myChannels->toggle(count > 0, anim::type::instant);