diff --git a/Telegram/SourceFiles/platform/linux/notifications_manager_linux.cpp b/Telegram/SourceFiles/platform/linux/notifications_manager_linux.cpp index 67abd46b8..b8c2f77b3 100644 --- a/Telegram/SourceFiles/platform/linux/notifications_manager_linux.cpp +++ b/Telegram/SourceFiles/platform/linux/notifications_manager_linux.cpp @@ -720,11 +720,8 @@ void Manager::Private::showNotification( oldNotification->id, nullptr); }); - clearNotification(notificationId); - i = _notifications.find(key); } - } - if (i == end(_notifications)) { + } else { i = _notifications.emplace(key).first; } v::match(notification, [&](Gio::Notification ¬ification) { @@ -814,16 +811,11 @@ void Manager::Private::showNotification( void Manager::Private::clearAll() { for (const auto &[key, notifications] : base::take(_notifications)) { for (const auto &[msgId, notification] : notifications) { - const auto notificationId = NotificationId{ - .contextId = key, - .msgId = msgId, - }; v::match(notification, [&](const std::string ¬ification) { _application.withdraw_notification(notification); }, [&](const Notification ¬ification) { _interface.call_close_notification(notification->id, nullptr); }); - clearNotification(notificationId); } } } @@ -834,10 +826,6 @@ void Manager::Private::clearFromItem(not_null item) { .peerId = item->history()->peer->id, .topicRootId = item->topicRootId(), }; - const auto notificationId = NotificationId{ - .contextId = key, - .msgId = item->id, - }; const auto i = _notifications.find(key); if (i == _notifications.cend()) { return; @@ -856,7 +844,6 @@ void Manager::Private::clearFromItem(not_null item) { }, [&](const Notification &taken) { _interface.call_close_notification(taken->id, nullptr); }); - clearNotification(notificationId); } void Manager::Private::clearFromTopic(not_null topic) { @@ -870,16 +857,11 @@ void Manager::Private::clearFromTopic(not_null topic) { _notifications.erase(i); for (const auto &[msgId, notification] : temp) { - const auto notificationId = NotificationId{ - .contextId = key, - .msgId = msgId, - }; v::match(notification, [&](const std::string ¬ification) { _application.withdraw_notification(notification); }, [&](const Notification ¬ification) { _interface.call_close_notification(notification->id, nullptr); }); - clearNotification(notificationId); } } } @@ -887,11 +869,10 @@ void Manager::Private::clearFromTopic(not_null topic) { void Manager::Private::clearFromHistory(not_null history) { const auto sessionId = history->session().uniqueId(); const auto peerId = history->peer->id; - const auto key = ContextId{ + auto i = _notifications.lower_bound(ContextId{ .sessionId = sessionId, .peerId = peerId, - }; - auto i = _notifications.lower_bound(key); + }); while (i != _notifications.cend() && i->first.sessionId == sessionId && i->first.peerId == peerId) { @@ -899,41 +880,30 @@ void Manager::Private::clearFromHistory(not_null history) { i = _notifications.erase(i); for (const auto &[msgId, notification] : temp) { - const auto notificationId = NotificationId{ - .contextId = key, - .msgId = msgId, - }; v::match(notification, [&](const std::string ¬ification) { _application.withdraw_notification(notification); }, [&](const Notification ¬ification) { _interface.call_close_notification(notification->id, nullptr); }); - clearNotification(notificationId); } } } void Manager::Private::clearFromSession(not_null session) { const auto sessionId = session->uniqueId(); - const auto key = ContextId{ + auto i = _notifications.lower_bound(ContextId{ .sessionId = sessionId, - }; - auto i = _notifications.lower_bound(key); + }); while (i != _notifications.cend() && i->first.sessionId == sessionId) { const auto temp = base::take(i->second); i = _notifications.erase(i); for (const auto &[msgId, notification] : temp) { - const auto notificationId = NotificationId{ - .contextId = key, - .msgId = msgId, - }; v::match(notification, [&](const std::string ¬ification) { _application.withdraw_notification(notification); }, [&](const Notification ¬ification) { _interface.call_close_notification(notification->id, nullptr); }); - clearNotification(notificationId); } } }