2
0
mirror of https://github.com/kotatogram/kotatogram-desktop synced 2025-08-31 06:35:14 +00:00

Hide native notifications of deleted messages.

This commit is contained in:
John Preston
2021-10-15 17:57:27 +04:00
parent 1f95e00793
commit d361f5c6b0
7 changed files with 108 additions and 16 deletions

View File

@@ -828,6 +828,7 @@ public:
const QString &msg,
DisplayOptions options);
void clearAll();
void clearFromItem(not_null<HistoryItem*> item);
void clearFromHistory(not_null<History*> history);
void clearFromSession(not_null<Main::Session*> session);
void clearNotification(NotificationId id);
@@ -943,6 +944,30 @@ void Manager::Private::clearAll() {
}
}
void Manager::Private::clearFromItem(not_null<HistoryItem*> item) {
if (!Supported()) {
return;
}
const auto key = FullPeer{
.sessionId = item->history()->session().uniqueId(),
.peerId = item->history()->peer->id
};
const auto i = _notifications.find(key);
if (i == _notifications.cend()) {
return;
}
const auto j = i->second.find(item->id);
if (j == i->second.end()) {
return;
}
const auto taken = base::take(j->second);
i->second.erase(j);
if (i->second.empty()) {
_notifications.erase(i);
}
taken->close();
}
void Manager::Private::clearFromHistory(not_null<History*> history) {
if (!Supported()) {
return;
@@ -952,7 +977,7 @@ void Manager::Private::clearFromHistory(not_null<History*> history) {
.sessionId = history->session().uniqueId(),
.peerId = history->peer->id
};
auto i = _notifications.find(key);
const auto i = _notifications.find(key);
if (i != _notifications.cend()) {
const auto temp = base::take(i->second);
_notifications.erase(i);
@@ -1033,6 +1058,10 @@ void Manager::doClearAllFast() {
_private->clearAll();
}
void Manager::doClearFromItem(not_null<HistoryItem*> item) {
_private->clearFromItem(item);
}
void Manager::doClearFromHistory(not_null<History*> history) {
_private->clearFromHistory(history);
}

View File

@@ -28,6 +28,7 @@ protected:
const QString &msg,
DisplayOptions options) override;
void doClearAllFast() override;
void doClearFromItem(not_null<HistoryItem*> item) override;
void doClearFromHistory(not_null<History*> history) override;
void doClearFromSession(not_null<Main::Session*> session) override;
bool doSkipAudio() const override;