2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-08-31 14:38:15 +00:00

Apply ignore_restriction_reasons from config.

This commit is contained in:
John Preston
2019-12-09 16:57:33 +03:00
parent 431b7445c3
commit 41e13e39bc
13 changed files with 127 additions and 43 deletions

View File

@@ -41,6 +41,7 @@ void AppConfig::refresh() {
_requestId = 0;
refreshDelayed();
if (result.type() == mtpc_jsonObject) {
_data.clear();
for (const auto &element : result.c_jsonObject().vvalue().v) {
element.match([&](const MTPDjsonObjectValue &data) {
_data.emplace_or_assign(qs(data.vkey()), data.vvalue());
@@ -94,4 +95,23 @@ QString AppConfig::getString(
});
}
std::vector<QString> AppConfig::getStringArray(
const QString &key,
std::vector<QString> &&fallback) const {
return getValue(key, [&](const MTPJSONValue &value) {
return value.match([&](const MTPDjsonArray &data) {
auto result = std::vector<QString>();
for (const auto &entry : data.vvalue().v) {
if (entry.type() != mtpc_jsonString) {
return std::move(fallback);
}
result.push_back(qs(entry.c_jsonString().vvalue()));
}
return result;
}, [&](const auto &data) {
return std::move(fallback);
});
});
}
} // namespace Main