Fix Ctrl+Tab/Ctrl+Shift+Tab jumps in topics.

This commit is contained in:
John Preston 2022-12-06 14:32:34 +04:00
parent a1de77e8d2
commit 4db2b83c9b
2 changed files with 41 additions and 36 deletions

View file

@ -3360,8 +3360,8 @@ RowDescriptor InnerWidget::chatListEntryBefore(
return RowDescriptor(); return RowDescriptor();
} }
const auto whichHistory = which.key.history(); const auto whichThread = which.key.thread();
if (!whichHistory) { if (!whichThread) {
return RowDescriptor(); return RowDescriptor();
} }
if (!_searchResults.empty()) { if (!_searchResults.empty()) {
@ -3387,21 +3387,23 @@ RowDescriptor InnerWidget::chatListEntryBefore(
FullMsgId(PeerId(), ShowAtUnreadMsgId)); FullMsgId(PeerId(), ShowAtUnreadMsgId));
} }
} }
if (!_peerSearchResults.empty() if (const auto history = whichThread->asHistory()) {
&& _peerSearchResults[0]->peer == whichHistory->peer) { if (!_peerSearchResults.empty()
if (_filterResults.empty()) { && _peerSearchResults[0]->peer == history->peer) {
return RowDescriptor(); if (_filterResults.empty()) {
return RowDescriptor();
}
return RowDescriptor(
_filterResults.back().key(),
FullMsgId(PeerId(), ShowAtUnreadMsgId));
} }
return RowDescriptor( if (!_peerSearchResults.empty()) {
_filterResults.back().key(), for (auto b = _peerSearchResults.cbegin(), i = b + 1, e = _peerSearchResults.cend(); i != e; ++i) {
FullMsgId(PeerId(), ShowAtUnreadMsgId)); if ((*i)->peer == history->peer) {
} return RowDescriptor(
if (!_peerSearchResults.empty()) { session().data().history((*(i - 1))->peer),
for (auto b = _peerSearchResults.cbegin(), i = b + 1, e = _peerSearchResults.cend(); i != e; ++i) { FullMsgId(PeerId(), ShowAtUnreadMsgId));
if ((*i)->peer == whichHistory->peer) { }
return RowDescriptor(
session().data().history((*(i - 1))->peer),
FullMsgId(PeerId(), ShowAtUnreadMsgId));
} }
} }
} }
@ -3436,8 +3438,8 @@ RowDescriptor InnerWidget::chatListEntryAfter(
return RowDescriptor(); return RowDescriptor();
} }
const auto whichHistory = which.key.history(); const auto whichThread = which.key.thread();
if (!whichHistory) { if (!whichThread) {
return RowDescriptor(); return RowDescriptor();
} }
for (auto i = _searchResults.cbegin(), e = _searchResults.cend(); i != e; ++i) { for (auto i = _searchResults.cbegin(), e = _searchResults.cend(); i != e; ++i) {
@ -3450,19 +3452,21 @@ RowDescriptor InnerWidget::chatListEntryAfter(
return RowDescriptor(); return RowDescriptor();
} }
} }
for (auto i = _peerSearchResults.cbegin(), e = _peerSearchResults.cend(); i != e; ++i) { if (const auto history = whichThread->asHistory()) {
if ((*i)->peer == whichHistory->peer) { for (auto i = _peerSearchResults.cbegin(), e = _peerSearchResults.cend(); i != e; ++i) {
++i; if ((*i)->peer == history->peer) {
if (i != e) { ++i;
return RowDescriptor( if (i != e) {
session().data().history((*i)->peer), return RowDescriptor(
FullMsgId(PeerId(), ShowAtUnreadMsgId)); session().data().history((*i)->peer),
} else if (!_searchResults.empty()) { FullMsgId(PeerId(), ShowAtUnreadMsgId));
return RowDescriptor( } else if (!_searchResults.empty()) {
_searchResults.front()->item()->history(), return RowDescriptor(
_searchResults.front()->item()->fullId()); _searchResults.front()->item()->history(),
_searchResults.front()->item()->fullId());
}
return RowDescriptor();
} }
return RowDescriptor();
} }
} }
for (auto i = _filterResults.cbegin(), e = _filterResults.cend(); i != e; ++i) { for (auto i = _filterResults.cbegin(), e = _filterResults.cend(); i != e; ++i) {
@ -3651,7 +3655,8 @@ void InnerWidget::setupShortcuts() {
) | rpl::filter([=] { ) | rpl::filter([=] {
return isActiveWindow() return isActiveWindow()
&& !_controller->isLayerShown() && !_controller->isLayerShown()
&& !_controller->window().locked(); && !_controller->window().locked()
&& !_childListShown.current().shown;
}) | rpl::start_with_next([=](not_null<Shortcuts::Request*> request) { }) | rpl::start_with_next([=](not_null<Shortcuts::Request*> request) {
using Command = Shortcuts::Command; using Command = Shortcuts::Command;

View file

@ -1122,11 +1122,11 @@ bool SessionController::chatEntryHistoryMove(int steps) {
} }
bool SessionController::jumpToChatListEntry(Dialogs::RowDescriptor row) { bool SessionController::jumpToChatListEntry(Dialogs::RowDescriptor row) {
if (const auto history = row.key.history()) { if (const auto thread = row.key.thread()) {
showPeerHistory( showThread(
history, thread,
SectionShow::Way::ClearStack, row.fullId.msg,
row.fullId.msg); SectionShow::Way::ClearStack);
return true; return true;
} }
return false; return false;