2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-09-04 00:15:42 +00:00

Moved out top promo from api and suggestions from config to single file.

This commit is contained in:
23rd
2025-05-06 11:11:45 +03:00
parent dc1459438c
commit c2e887a86e
13 changed files with 288 additions and 205 deletions

View File

@@ -170,15 +170,6 @@ void AppConfig::refresh(bool force) {
}
updateIgnoredRestrictionReasons(std::move(was));
{
const auto dismissedSuggestions = get<std::vector<QString>>(
u"dismissed_suggestions"_q,
std::vector<QString>());
for (const auto &suggestion : dismissedSuggestions) {
_dismissedSuggestions.emplace(suggestion);
}
}
DEBUG_LOG(("getAppConfig result handled."));
_refreshed.fire({});
}, [](const MTPDhelp_appConfigNotModified &) {});
@@ -331,47 +322,6 @@ std::vector<int> AppConfig::getIntArray(
});
}
bool AppConfig::suggestionCurrent(const QString &key) const {
if (key == u"BIRTHDAY_CONTACTS_TODAY"_q) {
if (_dismissedSuggestions.contains(key)
|| !_account->sessionExists()) {
return false;
} else {
const auto known
= _account->session().data().knownBirthdaysToday();
if (!known) {
return true;
}
return !known->empty();
}
}
return !_dismissedSuggestions.contains(key)
&& ranges::contains(
get<std::vector<QString>>(
u"pending_suggestions"_q,
std::vector<QString>()),
key);
}
rpl::producer<> AppConfig::suggestionRequested(const QString &key) const {
return value(
) | rpl::filter([=] {
return suggestionCurrent(key);
});
}
void AppConfig::dismissSuggestion(const QString &key) {
Expects(_api.has_value());
if (!_dismissedSuggestions.emplace(key).second) {
return;
}
_api->request(MTPhelp_DismissSuggestion(
MTP_inputPeerEmpty(),
MTP_string(key)
)).send();
}
bool AppConfig::newRequirePremiumFree() const {
return get<bool>(
u"new_noncontact_peers_require_premium_without_ownpremium"_q,