mirror of
https://github.com/vale981/tdesktop
synced 2025-03-06 02:01:40 -05:00
Fix typing / send action updates handling.
This commit is contained in:
parent
d3c5ed08ab
commit
60a991bcb0
2 changed files with 44 additions and 2 deletions
|
@ -686,6 +686,40 @@ public:
|
||||||
}
|
}
|
||||||
return { where, false };
|
return { where, false };
|
||||||
}
|
}
|
||||||
|
std::pair<iterator, bool> insert_or_assign(
|
||||||
|
const Key &key,
|
||||||
|
const Type &value) {
|
||||||
|
if (this->empty() || this->compare()(key, this->front().first)) {
|
||||||
|
this->impl().emplace_front(key, value);
|
||||||
|
return { this->begin(), true };
|
||||||
|
} else if (this->compare()(this->back().first, key)) {
|
||||||
|
this->impl().emplace_back(key, value);
|
||||||
|
return { this->end() - 1, true };
|
||||||
|
}
|
||||||
|
auto where = this->getLowerBound(key);
|
||||||
|
if (this->compare()(key, where->first)) {
|
||||||
|
return { this->impl().insert(where, value_type(key, value)), true };
|
||||||
|
}
|
||||||
|
where->second = value;
|
||||||
|
return { where, false };
|
||||||
|
}
|
||||||
|
std::pair<iterator, bool> insert_or_assign(
|
||||||
|
const Key &key,
|
||||||
|
Type &&value) {
|
||||||
|
if (this->empty() || this->compare()(key, this->front().first)) {
|
||||||
|
this->impl().emplace_front(key, std::move(value));
|
||||||
|
return { this->begin(), true };
|
||||||
|
} else if (this->compare()(this->back().first, key)) {
|
||||||
|
this->impl().emplace_back(key, std::move(value));
|
||||||
|
return { this->end() - 1, true };
|
||||||
|
}
|
||||||
|
auto where = this->getLowerBound(key);
|
||||||
|
if (this->compare()(key, where->first)) {
|
||||||
|
return { this->impl().insert(where, value_type(key, std::move(value))), true };
|
||||||
|
}
|
||||||
|
where->second = std::move(value);
|
||||||
|
return { where, false };
|
||||||
|
}
|
||||||
template <typename... Args>
|
template <typename... Args>
|
||||||
std::pair<iterator, bool> emplace(
|
std::pair<iterator, bool> emplace(
|
||||||
const Key &key,
|
const Key &key,
|
||||||
|
@ -695,6 +729,14 @@ public:
|
||||||
Type(std::forward<Args>(args)...)));
|
Type(std::forward<Args>(args)...)));
|
||||||
}
|
}
|
||||||
template <typename... Args>
|
template <typename... Args>
|
||||||
|
std::pair<iterator, bool> emplace_or_assign(
|
||||||
|
const Key &key,
|
||||||
|
Args&&... args) {
|
||||||
|
return this->insert_or_assign(
|
||||||
|
key,
|
||||||
|
Type(std::forward<Args>(args)...));
|
||||||
|
}
|
||||||
|
template <typename... Args>
|
||||||
std::pair<iterator, bool> try_emplace(
|
std::pair<iterator, bool> try_emplace(
|
||||||
const Key &key,
|
const Key &key,
|
||||||
Args&&... args) {
|
Args&&... args) {
|
||||||
|
|
|
@ -358,10 +358,10 @@ bool History::updateSendActionNeedsAnimating(
|
||||||
Type type,
|
Type type,
|
||||||
crl::time duration,
|
crl::time duration,
|
||||||
int progress = 0) {
|
int progress = 0) {
|
||||||
_sendActions.emplace(user, type, now + duration, progress);
|
_sendActions.emplace_or_assign(user, type, now + duration, progress);
|
||||||
};
|
};
|
||||||
action.match([&](const MTPDsendMessageTypingAction &) {
|
action.match([&](const MTPDsendMessageTypingAction &) {
|
||||||
_typing.emplace(user, now + kStatusShowClientsideTyping);
|
_typing.emplace_or_assign(user, now + kStatusShowClientsideTyping);
|
||||||
}, [&](const MTPDsendMessageRecordVideoAction &) {
|
}, [&](const MTPDsendMessageRecordVideoAction &) {
|
||||||
emplaceAction(Type::RecordVideo, kStatusShowClientsideRecordVideo);
|
emplaceAction(Type::RecordVideo, kStatusShowClientsideRecordVideo);
|
||||||
}, [&](const MTPDsendMessageRecordAudioAction &) {
|
}, [&](const MTPDsendMessageRecordAudioAction &) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue