Make notifications more useful

- Refactor and cleanup code
- Don't paginate through notifications - it spams the server with requests and realistically only contains anything relevant on startup after a long time, in which case you're going to lose some notification anyway
- Only show newest notification for the respective room, closing the old notification if one exists
- Only show text of this notification

BUG: 475228
This commit is contained in:
Tobias Fella
2024-06-10 20:47:59 +02:00
parent 6fdb22a5b5
commit a0c8bdf021
4 changed files with 84 additions and 78 deletions

View File

@@ -47,8 +47,13 @@ public:
/**
* @brief Display a native notification for an message.
*/
Q_INVOKABLE void
postNotification(NeoChatRoom *room, const QString &sender, const QString &text, const QImage &icon, const QString &replyEventId, bool canReply);
Q_INVOKABLE void postNotification(NeoChatRoom *room,
const QString &sender,
const QString &text,
const QImage &icon,
const QString &replyEventId,
bool canReply,
qint64 timestamp);
/**
* @brief Display a native notification for an invite.
@@ -82,7 +87,7 @@ private:
bool shouldPostNotification(QPointer<NeoChatConnection> connection, const QJsonValue &notification);
QHash<QString, KNotification *> m_notifications;
QHash<QString, std::pair<qint64, KNotification *>> m_notifications;
QHash<QString, QPointer<KNotification>> m_invitations;
private Q_SLOTS: