MCPcopy Create free account
hub / github.com/TDesktop-x64/tdesktop / setupShortcuts

Method setupShortcuts

Telegram/SourceFiles/dialogs/dialogs_inner_widget.cpp:5446–5624  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5444}
5445
5446void InnerWidget::setupShortcuts() {
5447 Shortcuts::Requests(
5448 ) | rpl::filter([=] {
5449 return isActiveWindow()
5450 && !_controller->isLayerShown()
5451 && !_controller->window().locked()
5452 && !_childListShown.current().shown
5453 && !_chatPreviewRow.key;
5454 }) | rpl::on_next([=](not_null<Shortcuts::Request*> request) {
5455 using Command = Shortcuts::Command;
5456
5457 const auto row = _controller->activeChatEntryCurrent();
5458 // Those should be computed before the call to request->handle.
5459 const auto previous = row.key
5460 ? computeJump(
5461 chatListEntryBefore(row),
5462 JumpSkip::PreviousOrBegin)
5463 : row;
5464 const auto next = row.key
5465 ? computeJump(
5466 chatListEntryAfter(row),
5467 JumpSkip::NextOrEnd)
5468 : row;
5469 const auto first = [&] {
5470 const auto to = chatListEntryFirst();
5471 const auto jump = computeJump(to, JumpSkip::NextOrOriginal);
5472 return (to == row || jump == row || to == previous) ? to : jump;
5473 }();
5474 const auto last = [&] {
5475 const auto to = chatListEntryLast();
5476 const auto jump = computeJump(to, JumpSkip::PreviousOrOriginal);
5477 return (to == row || jump == row || to == next) ? to : jump;
5478 }();
5479 if (row.key) {
5480 request->check(Command::ChatPrevious) && request->handle([=] {
5481 return jumpToDialogRow(previous);
5482 });
5483 request->check(Command::ChatNext) && request->handle([=] {
5484 return jumpToDialogRow(next);
5485 });
5486 } else if (_state == WidgetState::Default
5487 ? !_shownList->empty()
5488 : !_filterResults.empty()) {
5489 request->check(Command::ChatNext) && request->handle([=] {
5490 return jumpToDialogRow(first);
5491 });
5492 }
5493 request->check(Command::ChatFirst) && request->handle([=] {
5494 return jumpToDialogRow(first);
5495 });
5496 request->check(Command::ChatLast) && request->handle([=] {
5497 return jumpToDialogRow(last);
5498 });
5499 request->check(Command::ChatSelf) && request->handle([=] {
5500 _controller->showThread(
5501 session().data().history(session().user()),
5502 ShowAtUnreadMsgId,
5503 Window::SectionShow::Way::ClearStack);

Callers

nothing calls this directly

Calls 15

RequestsFunction · 0.85
PinnedDialogsCountFunction · 0.85
FixedOnTopDialogsCountFunction · 0.85
IsUnreadThreadFunction · 0.85
MarkAsReadThreadFunction · 0.85
ToggleHistoryArchivedFunction · 0.85
PrepareContactsBoxFunction · 0.85
handleMethod · 0.80
showThreadMethod · 0.80
folderLoadedMethod · 0.80

Tested by

no test coverage detected