mirror of
https://github.com/telegramdesktop/tdesktop
synced 2024-12-28 09:32:56 +00:00
Fix clearing session notifications.
This commit is contained in:
parent
c3fa300b5c
commit
613a2f358a
@ -582,7 +582,9 @@ void Manager::Private::showNotification(
|
||||
const QString &msg,
|
||||
bool hideNameAndPhoto,
|
||||
bool hideReplyButton) {
|
||||
if (!Supported()) return;
|
||||
if (!Supported()) {
|
||||
return;
|
||||
}
|
||||
|
||||
const auto key = FullPeer{
|
||||
.sessionId = peer->session().uniqueId(),
|
||||
@ -630,7 +632,9 @@ void Manager::Private::showNotification(
|
||||
}
|
||||
|
||||
void Manager::Private::clearAll() {
|
||||
if (!Supported()) return;
|
||||
if (!Supported()) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (const auto &[key, notifications] : base::take(_notifications)) {
|
||||
for (const auto &[msgId, notification] : notifications) {
|
||||
@ -640,7 +644,9 @@ void Manager::Private::clearAll() {
|
||||
}
|
||||
|
||||
void Manager::Private::clearFromHistory(not_null<History*> history) {
|
||||
if (!Supported()) return;
|
||||
if (!Supported()) {
|
||||
return;
|
||||
}
|
||||
|
||||
const auto key = FullPeer{
|
||||
.sessionId = history->session().uniqueId(),
|
||||
@ -658,23 +664,29 @@ void Manager::Private::clearFromHistory(not_null<History*> history) {
|
||||
}
|
||||
|
||||
void Manager::Private::clearFromSession(not_null<Main::Session*> session) {
|
||||
if (!Supported()) return;
|
||||
if (!Supported()) {
|
||||
return;
|
||||
}
|
||||
|
||||
const auto sessionId = session->uniqueId();
|
||||
for (auto i = _notifications.begin(); i != _notifications.end();) {
|
||||
if (i->first.sessionId == sessionId) {
|
||||
const auto temp = base::take(i->second);
|
||||
i = _notifications.erase(i);
|
||||
if (i->first.sessionId != sessionId) {
|
||||
++i;
|
||||
continue;
|
||||
}
|
||||
const auto temp = base::take(i->second);
|
||||
i = _notifications.erase(i);
|
||||
|
||||
for (const auto &[msgId, notification] : temp) {
|
||||
notification->close();
|
||||
}
|
||||
for (const auto &[msgId, notification] : temp) {
|
||||
notification->close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Manager::Private::clearNotification(NotificationId id) {
|
||||
if (!Supported()) return;
|
||||
if (!Supported()) {
|
||||
return;
|
||||
}
|
||||
|
||||
auto i = _notifications.find(id.full);
|
||||
if (i != _notifications.cend()) {
|
||||
|
@ -415,7 +415,9 @@ Manager::Private::~Private() {
|
||||
}
|
||||
|
||||
void Manager::Private::clearAll() {
|
||||
if (!_notifier) return;
|
||||
if (!_notifier) {
|
||||
return;
|
||||
}
|
||||
|
||||
auto temp = base::take(_notifications);
|
||||
for (const auto &[key, notifications] : base::take(_notifications)) {
|
||||
@ -426,7 +428,9 @@ void Manager::Private::clearAll() {
|
||||
}
|
||||
|
||||
void Manager::Private::clearFromHistory(not_null<History*> history) {
|
||||
if (!_notifier) return;
|
||||
if (!_notifier) {
|
||||
return;
|
||||
}
|
||||
|
||||
auto i = _notifications.find(FullPeer{
|
||||
.sessionId = history->session().uniqueId(),
|
||||
@ -443,17 +447,21 @@ void Manager::Private::clearFromHistory(not_null<History*> history) {
|
||||
}
|
||||
|
||||
void Manager::Private::clearFromSession(not_null<Main::Session*> session) {
|
||||
if (!_notifier) return;
|
||||
if (!_notifier) {
|
||||
return;
|
||||
}
|
||||
|
||||
const auto sessionId = session->uniqueId();
|
||||
for (auto i = _notifications.begin(); i != _notifications.end();) {
|
||||
if (i->first.sessionId == sessionId) {
|
||||
const auto temp = base::take(i->second);
|
||||
_notifications.erase(i);
|
||||
if (i->first.sessionId != sessionId) {
|
||||
++i;
|
||||
continue;
|
||||
}
|
||||
const auto temp = base::take(i->second);
|
||||
_notifications.erase(i);
|
||||
|
||||
for (const auto &[msgId, notification] : temp) {
|
||||
_notifier->Hide(notification.p.Get());
|
||||
}
|
||||
for (const auto &[msgId, notification] : temp) {
|
||||
_notifier->Hide(notification.p.Get());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -207,15 +207,15 @@ void System::clearFromSession(not_null<Main::Session*> session) {
|
||||
|
||||
for (auto i = _whenMaps.begin(); i != _whenMaps.end();) {
|
||||
const auto history = i->first;
|
||||
if (&history->session() == session) {
|
||||
history->clearNotifications();
|
||||
i = _whenMaps.erase(i);
|
||||
_whenAlerts.remove(history);
|
||||
_waiters.remove(history);
|
||||
_settingWaiters.remove(history);
|
||||
} else {
|
||||
if (&history->session() != session) {
|
||||
++i;
|
||||
continue;
|
||||
}
|
||||
history->clearNotifications();
|
||||
i = _whenMaps.erase(i);
|
||||
_whenAlerts.remove(history);
|
||||
_waiters.remove(history);
|
||||
_settingWaiters.remove(history);
|
||||
}
|
||||
const auto clearFrom = [&](auto &map) {
|
||||
for (auto i = map.begin(); i != map.end();) {
|
||||
|
Loading…
Reference in New Issue
Block a user