mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Use flat_map::remove in clearFrom{Topic,Item}
Now that notification closing happens in destructor, the iterator is no more needed
This commit is contained in:
parent
4ac48d0e4a
commit
700e10d32c
1 changed files with 11 additions and 22 deletions
|
@ -789,35 +789,24 @@ void Manager::Private::clearAll() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Manager::Private::clearFromItem(not_null<HistoryItem*> item) {
|
void Manager::Private::clearFromItem(not_null<HistoryItem*> item) {
|
||||||
const auto key = ContextId{
|
const auto i = _notifications.find(ContextId{
|
||||||
.sessionId = item->history()->session().uniqueId(),
|
.sessionId = item->history()->session().uniqueId(),
|
||||||
.peerId = item->history()->peer->id,
|
.peerId = item->history()->peer->id,
|
||||||
.topicRootId = item->topicRootId(),
|
.topicRootId = item->topicRootId(),
|
||||||
};
|
});
|
||||||
const auto i = _notifications.find(key);
|
if (i != _notifications.cend()
|
||||||
if (i == _notifications.cend()) {
|
&& i->second.remove(item->id)
|
||||||
return;
|
&& i->second.empty()) {
|
||||||
}
|
|
||||||
const auto j = i->second.find(item->id);
|
|
||||||
if (j == i->second.end()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
i->second.erase(j);
|
|
||||||
if (i->second.empty()) {
|
|
||||||
_notifications.erase(i);
|
_notifications.erase(i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Manager::Private::clearFromTopic(not_null<Data::ForumTopic*> topic) {
|
void Manager::Private::clearFromTopic(not_null<Data::ForumTopic*> topic) {
|
||||||
const auto key = ContextId{
|
_notifications.remove(ContextId{
|
||||||
.sessionId = topic->session().uniqueId(),
|
.sessionId = topic->session().uniqueId(),
|
||||||
.peerId = topic->history()->peer->id,
|
.peerId = topic->history()->peer->id,
|
||||||
.topicRootId = topic->rootId(),
|
.topicRootId = topic->rootId(),
|
||||||
};
|
});
|
||||||
const auto i = _notifications.find(key);
|
|
||||||
if (i != _notifications.cend()) {
|
|
||||||
_notifications.erase(i);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Manager::Private::clearFromHistory(not_null<History*> history) {
|
void Manager::Private::clearFromHistory(not_null<History*> history) {
|
||||||
|
@ -846,10 +835,10 @@ void Manager::Private::clearFromSession(not_null<Main::Session*> session) {
|
||||||
|
|
||||||
void Manager::Private::clearNotification(NotificationId id) {
|
void Manager::Private::clearNotification(NotificationId id) {
|
||||||
auto i = _notifications.find(id.contextId);
|
auto i = _notifications.find(id.contextId);
|
||||||
if (i != _notifications.cend()) {
|
if (i != _notifications.cend()
|
||||||
if (i->second.remove(id.msgId) && i->second.empty()) {
|
&& i->second.remove(id.msgId)
|
||||||
_notifications.erase(i);
|
&& i->second.empty()) {
|
||||||
}
|
_notifications.erase(i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue