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

Save pinned chats in filters to server.

This commit is contained in:
John Preston
2020-03-17 18:52:01 +04:00
parent e27a8fe058
commit 55900bbd3d
13 changed files with 112 additions and 79 deletions

View File

@@ -1921,6 +1921,9 @@ void History::setFolderPointer(Data::Folder *folder) {
if (_folder == folder) {
return;
}
if (isPinnedDialog(FilterId())) {
owner().setChatPinned(this, FilterId(), false);
}
auto &filters = owner().chatsFilters();
const auto wasKnown = folderKnown();
const auto wasInList = inChatList();
@@ -1943,7 +1946,6 @@ void History::setFolderPointer(Data::Folder *folder) {
for (const auto &filter : filters.list()) {
if (filter.contains(this)) {
const auto id = filter.id();
applyFilterPinnedIndex(id, filter);
addToChatList(id, filters.chatsList(id));
}
}
@@ -1957,24 +1959,6 @@ void History::setFolderPointer(Data::Folder *folder) {
}
}
void History::applyFilterPinnedIndex(
FilterId filterId,
const Data::ChatFilter &filter) {
const auto &pinned = filter.pinned();
const auto i = ranges::find(pinned, this);
if (i == end(pinned)) {
return;
}
const auto index = (i - begin(pinned)) + 1;
if (index == lookupPinnedIndex(filterId)) {
return;
}
owner().chatsFilters().chatsList(filterId)->pinned()->applyFilterPinned(
filterId,
this,
index);
}
void History::applyPinnedUpdate(const MTPDupdateDialogPinned &data) {
const auto folderId = data.vfolder_id().value_or_empty();
if (!folderKnown()) {