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

Add base::optional as a wrapper of base::variant.

This commit is contained in:
John Preston
2017-08-14 13:38:23 +03:00
parent ae1dacb7d7
commit bca444b92e
10 changed files with 295 additions and 74 deletions

View File

@@ -1174,11 +1174,10 @@ void History::setUnreadMentionsCount(int count) {
}
bool History::addToUnreadMentions(MsgId msgId, AddToOverviewMethod method) {
auto count = base::get_if(&_unreadMentionsCount);
auto allLoaded = count ? (_unreadMentions.size() >= *count) : false;
auto allLoaded = _unreadMentionsCount ? (_unreadMentions.size() >= *_unreadMentionsCount) : false;
if (allLoaded) {
if (method == AddToOverviewNew) {
++*count;
++*_unreadMentionsCount;
_unreadMentions.insert(msgId);
return true;
}
@@ -1191,9 +1190,9 @@ bool History::addToUnreadMentions(MsgId msgId, AddToOverviewMethod method) {
void History::eraseFromUnreadMentions(MsgId msgId) {
_unreadMentions.remove(msgId);
if (auto count = base::get_if(&_unreadMentionsCount)) {
if (*count > 0) {
--*count;
if (_unreadMentionsCount) {
if (*_unreadMentionsCount > 0) {
--*_unreadMentionsCount;
}
}
Notify::peerUpdatedDelayed(peer, Notify::PeerUpdate::Flag::UnreadMentionsChanged);