mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-22 17:17:15 +02:00
Switched order of data filter applying of changes from api.
This commit is contained in:
parent
f4523b2dba
commit
e3465da979
1 changed files with 8 additions and 6 deletions
|
@ -393,7 +393,8 @@ void ChatFilters::received(const QVector<MTPDialogFilter> &list) {
|
||||||
auto changed = false;
|
auto changed = false;
|
||||||
for (const auto &filter : list) {
|
for (const auto &filter : list) {
|
||||||
auto parsed = ChatFilter::FromTL(filter, _owner);
|
auto parsed = ChatFilter::FromTL(filter, _owner);
|
||||||
const auto b = begin(_list) + position, e = end(_list);
|
const auto b = begin(_list) + position;
|
||||||
|
const auto e = end(_list);
|
||||||
const auto i = ranges::find(b, e, parsed.id(), &ChatFilter::id);
|
const auto i = ranges::find(b, e, parsed.id(), &ChatFilter::id);
|
||||||
if (i == e) {
|
if (i == e) {
|
||||||
applyInsert(std::move(parsed), position);
|
applyInsert(std::move(parsed), position);
|
||||||
|
@ -621,11 +622,13 @@ bool ChatFilters::applyChange(ChatFilter &filter, ChatFilter &&updated) {
|
||||||
if (!listUpdated && !chatlistChanged) {
|
if (!listUpdated && !chatlistChanged) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
const auto wasFilter = std::move(filter);
|
||||||
|
filter = std::move(updated);
|
||||||
if (rulesChanged) {
|
if (rulesChanged) {
|
||||||
const auto filterList = _owner->chatsFilters().chatsList(id);
|
const auto filterList = _owner->chatsFilters().chatsList(id);
|
||||||
const auto feedHistory = [&](not_null<History*> history) {
|
const auto feedHistory = [&](not_null<History*> history) {
|
||||||
const auto now = updated.contains(history);
|
const auto now = filter.contains(history);
|
||||||
const auto was = filter.contains(history);
|
const auto was = wasFilter.contains(history);
|
||||||
if (now != was) {
|
if (now != was) {
|
||||||
if (now) {
|
if (now) {
|
||||||
history->addToChatList(id, filterList);
|
history->addToChatList(id, filterList);
|
||||||
|
@ -645,17 +648,16 @@ bool ChatFilters::applyChange(ChatFilter &filter, ChatFilter &&updated) {
|
||||||
if (const auto folder = _owner->folderLoaded(Data::Folder::kId)) {
|
if (const auto folder = _owner->folderLoaded(Data::Folder::kId)) {
|
||||||
feedList(folder->chatsList());
|
feedList(folder->chatsList());
|
||||||
}
|
}
|
||||||
if (exceptionsChanged && !updated.always().empty()) {
|
if (exceptionsChanged && !filter.always().empty()) {
|
||||||
_exceptionsToLoad.push_back(id);
|
_exceptionsToLoad.push_back(id);
|
||||||
Ui::PostponeCall(&_owner->session(), [=] {
|
Ui::PostponeCall(&_owner->session(), [=] {
|
||||||
_owner->session().api().requestMoreDialogsIfNeeded();
|
_owner->session().api().requestMoreDialogsIfNeeded();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
filter = std::move(updated);
|
|
||||||
if (pinnedChanged) {
|
if (pinnedChanged) {
|
||||||
const auto filterList = _owner->chatsFilters().chatsList(id);
|
const auto filterList = _owner->chatsFilters().chatsList(id);
|
||||||
filterList->pinned()->applyList(filter.pinned());
|
filterList->pinned()->applyList(wasFilter.pinned());
|
||||||
}
|
}
|
||||||
if (chatlistChanged) {
|
if (chatlistChanged) {
|
||||||
_isChatlistChanged.fire_copy(id);
|
_isChatlistChanged.fire_copy(id);
|
||||||
|
|
Loading…
Add table
Reference in a new issue