2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-09-03 07:56:03 +00:00

Fix drag-n-drop to frequent/recent contacts.

This commit is contained in:
John Preston
2024-05-19 12:05:01 +04:00
parent ba8bb2d50f
commit 1c6f45d8d3
7 changed files with 129 additions and 11 deletions

View File

@@ -1121,6 +1121,39 @@ void Suggestions::chooseRow() {
}
}
Data::Thread *Suggestions::updateFromParentDrag(QPoint globalPosition) {
return (_tab.current() == Tab::Chats)
? updateFromChatsDrag(globalPosition)
: updateFromChannelsDrag(globalPosition);
}
Data::Thread *Suggestions::updateFromChatsDrag(QPoint globalPosition) {
if (const auto top = _topPeers->updateFromParentDrag(globalPosition)) {
return _controller->session().data().history(PeerId(top));
}
return fromListId(_recentUpdateFromParentDrag(globalPosition));
}
Data::Thread *Suggestions::updateFromChannelsDrag(QPoint globalPosition) {
if (const auto id = _myChannelsUpdateFromParentDrag(globalPosition)) {
return fromListId(id);
}
return fromListId(_recommendationsUpdateFromParentDrag(globalPosition));
}
Data::Thread *Suggestions::fromListId(uint64 peerListRowId) {
return peerListRowId
? _controller->session().data().history(PeerId(peerListRowId)).get()
: nullptr;
}
void Suggestions::dragLeft() {
_topPeers->dragLeft();
_recentDragLeft();
_myChannelsDragLeft();
_recommendationsDragLeft();
}
void Suggestions::show(anim::type animated, Fn<void()> finish) {
RpWidget::show();
@@ -1304,6 +1337,12 @@ object_ptr<Ui::SlideWrap<>> Suggestions::setupRecentPeers(
}
return JumpResult::NotApplied;
};
_recentUpdateFromParentDrag = [=](QPoint globalPosition) {
return raw->updateFromParentDrag(globalPosition);
};
_recentDragLeft = [=] {
raw->dragLeft();
};
raw->scrollToRequests(
) | rpl::start_with_next([this](Ui::ScrollToRequest request) {
const auto add = _topPeersWrap->toggled() ? _topPeers->height() : 0;
@@ -1438,6 +1477,12 @@ object_ptr<Ui::SlideWrap<>> Suggestions::setupMyChannels() {
}
return JumpResult::NotApplied;
};
_myChannelsUpdateFromParentDrag = [=](QPoint globalPosition) {
return raw->updateFromParentDrag(globalPosition);
};
_myChannelsDragLeft = [=] {
raw->dragLeft();
};
raw->scrollToRequests(
) | rpl::start_with_next([this](Ui::ScrollToRequest request) {
_channelsScroll->scrollToY(request.ymin, request.ymax);
@@ -1499,6 +1544,12 @@ object_ptr<Ui::SlideWrap<>> Suggestions::setupRecommendations() {
}
return JumpResult::NotApplied;
};
_recommendationsUpdateFromParentDrag = [=](QPoint globalPosition) {
return raw->updateFromParentDrag(globalPosition);
};
_recommendationsDragLeft = [=] {
raw->dragLeft();
};
raw->scrollToRequests(
) | rpl::start_with_next([this](Ui::ScrollToRequest request) {
const auto add = _myChannels->toggled() ? _myChannels->height() : 0;