mirror of https://github.com/procxx/kepka.git
Filter emoji languages by server.
This commit is contained in:
parent
24dcde2f87
commit
dba677dcc7
|
@ -426,7 +426,7 @@ void EmojiKeywords::apiChanged(ApiWrap *api) {
|
||||||
refresh();
|
refresh();
|
||||||
}, _suggestedChangeLifetime);
|
}, _suggestedChangeLifetime);
|
||||||
} else {
|
} else {
|
||||||
_remoteListRequestId = 0;
|
_langsRequestId = 0;
|
||||||
_suggestedChangeLifetime.destroy();
|
_suggestedChangeLifetime.destroy();
|
||||||
}
|
}
|
||||||
for (const auto &[language, item] : _data) {
|
for (const auto &[language, item] : _data) {
|
||||||
|
@ -484,10 +484,25 @@ void EmojiKeywords::refreshRemoteList() {
|
||||||
setRemoteList({});
|
setRemoteList({});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
_api->request(base::take(_remoteListRequestId)).cancel();
|
_api->request(base::take(_langsRequestId)).cancel();
|
||||||
//_remoteListRequestId = _api->request() // #TODO emoji
|
auto languages = QVector<MTPstring>();
|
||||||
setRemoteList(base::duplicate(_localList));
|
for (const auto &id : _localList) {
|
||||||
auto list = _localList;
|
languages.push_back(MTP_string(id));
|
||||||
|
}
|
||||||
|
_langsRequestId = _api->request(MTPmessages_GetEmojiKeywordsLanguages(
|
||||||
|
MTP_vector<MTPstring>(languages)
|
||||||
|
)).done([=](const MTPVector<MTPEmojiLanguage> &result) {
|
||||||
|
setRemoteList(ranges::view::all(
|
||||||
|
result.v
|
||||||
|
) | ranges::view::transform([](const MTPEmojiLanguage &language) {
|
||||||
|
return language.match([&](const MTPDemojiLanguage &language) {
|
||||||
|
return qs(language.vlang_code);
|
||||||
|
});
|
||||||
|
}) | ranges::to_vector);
|
||||||
|
_langsRequestId = 0;
|
||||||
|
}).fail([=](const RPCError &error) {
|
||||||
|
_langsRequestId = 0;
|
||||||
|
}).send();
|
||||||
}
|
}
|
||||||
|
|
||||||
void EmojiKeywords::setRemoteList(std::vector<QString> &&list) {
|
void EmojiKeywords::setRemoteList(std::vector<QString> &&list) {
|
||||||
|
|
|
@ -60,7 +60,7 @@ private:
|
||||||
ApiWrap *_api = nullptr;
|
ApiWrap *_api = nullptr;
|
||||||
std::vector<QString> _localList;
|
std::vector<QString> _localList;
|
||||||
std::vector<QString> _remoteList;
|
std::vector<QString> _remoteList;
|
||||||
mtpRequestId _remoteListRequestId = 0;
|
mtpRequestId _langsRequestId = 0;
|
||||||
base::flat_map<QString, std::unique_ptr<LangPack>> _data;
|
base::flat_map<QString, std::unique_ptr<LangPack>> _data;
|
||||||
rpl::event_stream<> _refreshed;
|
rpl::event_stream<> _refreshed;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue