2
0
mirror of https://github.com/kotatogram/kotatogram-desktop synced 2025-08-31 06:35:14 +00:00

Allow pinning chats in folders when 100 added.

This commit is contained in:
John Preston
2022-03-14 11:11:14 +04:00
parent d1a913450a
commit 3b9ac19482
3 changed files with 43 additions and 55 deletions

View File

@@ -1823,30 +1823,25 @@ void Session::applyDialog(
setPinnedFromDialog(folder, data.is_pinned());
}
int Session::pinnedChatsCount(
int Session::pinnedCanPin(
Data::Folder *folder,
FilterId filterId) const {
FilterId filterId,
not_null<History*> history) const {
if (!filterId) {
return pinnedChatsOrder(folder, filterId).size();
const auto limit = pinnedChatsLimit(folder);
return pinnedChatsOrder(folder, FilterId()).size() < limit;
}
const auto &list = chatsFilters().list();
const auto i = ranges::find(list, filterId, &Data::ChatFilter::id);
return (i != end(list)) ? i->pinned().size() : 0;
return (i == end(list))
|| (i->always().contains(history))
|| (i->always().size() < Data::ChatFilter::kPinnedLimit);
}
int Session::pinnedChatsLimit(
Data::Folder *folder,
FilterId filterId) const {
if (!filterId) {
return folder
? session().serverConfig().pinnedDialogsInFolderMax.current()
: session().serverConfig().pinnedDialogsCountMax.current();
}
const auto &list = chatsFilters().list();
const auto i = ranges::find(list, filterId, &Data::ChatFilter::id);
const auto pinned = (i != end(list)) ? i->pinned().size() : 0;
const auto already = (i != end(list)) ? i->always().size() : 0;
return Data::ChatFilter::kPinnedLimit + pinned - already;
int Session::pinnedChatsLimit(Data::Folder *folder) const {
return folder
? session().serverConfig().pinnedDialogsInFolderMax.current()
: session().serverConfig().pinnedDialogsCountMax.current();
}
const std::vector<Dialogs::Key> &Session::pinnedChatsOrder(