Fix Ctrl+[1-5] jump to pinned in folders.

This commit is contained in:
John Preston 2020-03-23 15:10:09 +04:00
parent 6022fa790e
commit d5b8fc703e
4 changed files with 13 additions and 8 deletions

View File

@ -1003,7 +1003,7 @@ void ApiWrap::requestPinnedDialogs(Data::Folder *folder) {
result.match([&](const MTPDmessages_peerDialogs &data) {
_session->data().processUsers(data.vusers());
_session->data().processChats(data.vchats());
_session->data().clearPinnedChats(folder, FilterId());
_session->data().clearPinnedChats(folder);
_session->data().applyDialogs(
folder,
data.vmessages().v,

View File

@ -1557,8 +1557,6 @@ void Session::applyDialog(
int Session::pinnedChatsCount(
Data::Folder *folder,
FilterId filterId) const {
Expects(!folder || !filterId);
if (!filterId) {
return pinnedChatsOrder(folder, filterId).size();
}
@ -1591,7 +1589,7 @@ const std::vector<Dialogs::Key> &Session::pinnedChatsOrder(
return list->pinned()->order();
}
void Session::clearPinnedChats(Data::Folder *folder, FilterId filterId) {
void Session::clearPinnedChats(Data::Folder *folder) {
chatsList(folder)->pinned()->clear();
}

View File

@ -371,7 +371,7 @@ public:
const Dialogs::Key &key,
FilterId filterId,
bool pinned);
void clearPinnedChats(Data::Folder *folder, FilterId filterId);
void clearPinnedChats(Data::Folder *folder);
void applyPinnedChats(
Data::Folder *folder,
const QVector<MTPDialogPeer> &list);

View File

@ -2999,11 +2999,18 @@ void InnerWidget::setupShortcuts() {
Command::ChatPinned4,
Command::ChatPinned5,
};
auto &&pinned = ranges::view::zip(kPinned, ranges::view::ints(0, ranges::unreachable));
auto &&pinned = ranges::view::zip(
kPinned,
ranges::view::ints(0, ranges::unreachable));
for (const auto [command, index] : pinned) {
request->check(command) && request->handle([=, index = index] {
const auto list = session().data().chatsList()->indexed();
const auto count = Dialogs::PinnedDialogsCount(_filterId, list);
const auto list = (_filterId
? session().data().chatsFilters().chatsList(_filterId)
: session().data().chatsList()
)->indexed();
const auto count = Dialogs::PinnedDialogsCount(
_filterId,
list);
if (index >= count) {
return false;
}