2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-09-03 16:05:57 +00:00

Added ability to switch between folders with shortcuts.

This commit is contained in:
23rd
2020-03-29 02:04:20 +03:00
parent 7b583596ec
commit df290605f4
3 changed files with 35 additions and 0 deletions

View File

@@ -3053,6 +3053,35 @@ void InnerWidget::setupShortcuts() {
});
}
const auto nearFolder = [=](bool isNext) {
const auto id = _controller->activeChatsFilterCurrent();
const auto list = &session().data().chatsFilters().list();
const auto it = (id == 0)
? begin(*list) - 1
: ranges::find(*list, id, &Data::ChatFilter::id);
if (it == end(*list) && id != 0) {
return false;
}
const auto i = isNext ? 1 : -1;
const auto index = it - begin(*list) + i;
if (index >= (int)list->size() || index < -1) {
return false;
}
const auto filterId = (index == -1)
? 0
: list->at(index).id();
_controller->setActiveChatsFilter(filterId);
return true;
};
request->check(Command::FolderNext) && request->handle([=] {
return nearFolder(true);
});
request->check(Command::FolderPrevious) && request->handle([=] {
return nearFolder(false);
});
if (session().supportMode() && row.key.history()) {
request->check(
Command::SupportScrollToCurrent