Locally update recent premium statuses when changing the status.
This commit is contained in:
parent
6f940b5e9b
commit
1890d45680
@ -6603,6 +6603,7 @@ void ContactsManager::set_emoji_status(EmojiStatus emoji_status, Promise<Unit> &
|
|||||||
if (!td_->option_manager_->get_option_boolean("is_premium")) {
|
if (!td_->option_manager_->get_option_boolean("is_premium")) {
|
||||||
return promise.set_error(Status::Error(400, "The method is available only for Telegram Premium users"));
|
return promise.set_error(Status::Error(400, "The method is available only for Telegram Premium users"));
|
||||||
}
|
}
|
||||||
|
add_recent_emoji_status(emoji_status);
|
||||||
auto query_promise = PromiseCreator::lambda(
|
auto query_promise = PromiseCreator::lambda(
|
||||||
[actor_id = actor_id(this), emoji_status, promise = std::move(promise)](Result<Unit> result) mutable {
|
[actor_id = actor_id(this), emoji_status, promise = std::move(promise)](Result<Unit> result) mutable {
|
||||||
if (result.is_ok()) {
|
if (result.is_ok()) {
|
||||||
|
@ -242,6 +242,22 @@ void get_recent_emoji_statuses(Td *td, Promise<td_api::object_ptr<td_api::premiu
|
|||||||
td->create_handler<GetRecentEmojiStatusesQuery>(std::move(promise))->send(statuses.hash_);
|
td->create_handler<GetRecentEmojiStatusesQuery>(std::move(promise))->send(statuses.hash_);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void add_recent_emoji_status(EmojiStatus emoji_status) {
|
||||||
|
if (emoji_status.is_empty()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto statuses = load_emoji_statuses(get_recent_emoji_statuses_database_key());
|
||||||
|
if (!statuses.emoji_statuses_.empty() && statuses.emoji_statuses_[0] == emoji_status) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
statuses.hash_ = 0;
|
||||||
|
td::remove(statuses.emoji_statuses_, emoji_status);
|
||||||
|
statuses.emoji_statuses_.insert(statuses.emoji_statuses_.begin(), emoji_status);
|
||||||
|
save_emoji_statuses(get_recent_emoji_statuses_database_key(), statuses);
|
||||||
|
}
|
||||||
|
|
||||||
void clear_recent_emoji_statuses(Td *td, Promise<Unit> &&promise) {
|
void clear_recent_emoji_statuses(Td *td, Promise<Unit> &&promise) {
|
||||||
save_emoji_statuses(get_recent_emoji_statuses_database_key(), EmojiStatuses());
|
save_emoji_statuses(get_recent_emoji_statuses_database_key(), EmojiStatuses());
|
||||||
td->create_handler<ClearRecentEmojiStatusesQuery>(std::move(promise))->send();
|
td->create_handler<ClearRecentEmojiStatusesQuery>(std::move(promise))->send();
|
||||||
|
@ -65,6 +65,8 @@ void get_default_emoji_statuses(Td *td, Promise<td_api::object_ptr<td_api::premi
|
|||||||
|
|
||||||
void get_recent_emoji_statuses(Td *td, Promise<td_api::object_ptr<td_api::premiumStatuses>> &&promise);
|
void get_recent_emoji_statuses(Td *td, Promise<td_api::object_ptr<td_api::premiumStatuses>> &&promise);
|
||||||
|
|
||||||
|
void add_recent_emoji_status(EmojiStatus emoji_status);
|
||||||
|
|
||||||
void clear_recent_emoji_statuses(Td *td, Promise<Unit> &&promise);
|
void clear_recent_emoji_statuses(Td *td, Promise<Unit> &&promise);
|
||||||
|
|
||||||
} // namespace td
|
} // namespace td
|
||||||
|
@ -31,7 +31,7 @@ string strip_empty_characters(string str, size_t max_length, bool strip_rtlo = f
|
|||||||
// checks if string is empty after strip_empty_characters
|
// checks if string is empty after strip_empty_characters
|
||||||
bool is_empty_string(const string &str) TD_WARN_UNUSED_RESULT;
|
bool is_empty_string(const string &str) TD_WARN_UNUSED_RESULT;
|
||||||
|
|
||||||
// calculates hash of list of uint32
|
// calculates hash of list of uint64
|
||||||
int64 get_vector_hash(const vector<uint64> &numbers) TD_WARN_UNUSED_RESULT;
|
int64 get_vector_hash(const vector<uint64> &numbers) TD_WARN_UNUSED_RESULT;
|
||||||
|
|
||||||
// returns emoji corresponding to the specified number
|
// returns emoji corresponding to the specified number
|
||||||
|
Loading…
x
Reference in New Issue
Block a user