mirror of
https://github.com/Nheko-Reborn/nheko.git
synced 2024-11-22 19:08:58 +03:00
Make edits replace the previous notification on Linux
This commit is contained in:
parent
bccab87a5c
commit
eb1e54c8df
1 changed files with 26 additions and 7 deletions
|
@ -82,8 +82,14 @@ NotificationsManager::postNotification(const mtx::responses::Notification ¬if
|
|||
const auto event_id = QString::fromStdString(mtx::accessors::event_id(notification.event));
|
||||
const auto room_name = QString::fromStdString(cache::singleRoomInfo(notification.room_id).name);
|
||||
|
||||
auto postNotif = [this, room_id, event_id, room_name, icon](QString text) {
|
||||
const auto replaces_event_id =
|
||||
QString::fromStdString(mtx::accessors::relations(notification.event).replaces().value_or(""));
|
||||
|
||||
auto postNotif = [this, room_id, event_id, room_name, icon, replaces_event_id](QString text) {
|
||||
if (replaces_event_id.isEmpty())
|
||||
emit systemPostNotificationCb(room_id, event_id, room_name, text, icon);
|
||||
else
|
||||
emit systemPostNotificationCb(room_id, replaces_event_id, room_name, text, icon);
|
||||
};
|
||||
|
||||
QString template_ = getMessageTemplate(notification);
|
||||
|
@ -149,9 +155,22 @@ NotificationsManager::systemPostNotification(const QString &room_id,
|
|||
hints["desktop-entry"] = "nheko";
|
||||
hints["category"] = "im.received";
|
||||
|
||||
uint replace_id = 0;
|
||||
if (!event_id.isEmpty()) {
|
||||
for (auto elem = notificationIds.begin(); elem != notificationIds.end(); ++elem) {
|
||||
if (elem.value().roomId != room_id)
|
||||
continue;
|
||||
|
||||
if (elem.value().eventId == event_id) {
|
||||
replace_id = elem.key();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
QList<QVariant> argumentList;
|
||||
argumentList << "nheko"; // app_name
|
||||
argumentList << (uint)0; // replace_id
|
||||
argumentList << (uint)replace_id; // replace_id
|
||||
argumentList << ""; // app_icon
|
||||
argumentList << roomName; // summary
|
||||
argumentList << text; // body
|
||||
|
|
Loading…
Reference in a new issue