2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-08-30 22:16:14 +00:00

Update API scheme to layer 100.

This commit is contained in:
John Preston
2019-05-20 16:57:25 +02:00
parent 68fb9b8b67
commit c4aac5fa0e
26 changed files with 325 additions and 169 deletions

View File

@@ -4292,7 +4292,36 @@ void MainWidget::feedUpdate(const MTPUpdate &update) {
case mtpc_updatePrivacy: {
auto &d = update.c_updatePrivacy();
session().api().handlePrivacyChange(d.vkey.type(), d.vrules);
const auto allChatsLoaded = [&](const MTPVector<MTPint> &ids) {
for (const auto &chatId : ids.v) {
if (!session().data().chatLoaded(chatId.v)
&& !session().data().channelLoaded(chatId.v)) {
return false;
}
}
return true;
};
const auto allLoaded = [&] {
for (const auto &rule : d.vrules.v) {
const auto loaded = rule.match([&](
const MTPDprivacyValueAllowChatParticipants & data) {
return allChatsLoaded(data.vchats);
}, [&](const MTPDprivacyValueDisallowChatParticipants & data) {
return allChatsLoaded(data.vchats);
}, [](auto &&) { return true; });
if (!loaded) {
return false;
}
}
return true;
};
if (const auto key = ApiWrap::Privacy::KeyFromMTP(d.vkey.type())) {
if (allLoaded()) {
session().api().handlePrivacyChange(*key, d.vrules);
} else {
session().api().reloadPrivacy(*key);
}
}
} break;
case mtpc_updatePinnedDialogs: {