Show notifications

This commit is contained in:
Tobias Fella
2020-11-18 00:50:07 +01:00
parent 9c469b96f1
commit 039816e8eb
10 changed files with 75 additions and 2 deletions

View File

@@ -31,6 +31,7 @@
#include "jobs/downloadfilejob.h"
#include "user.h"
#include "utils.h"
#include "notificationsmanager.h"
#include <KLocalizedString>
@@ -43,6 +44,18 @@ NeoChatRoom::NeoChatRoom(Connection *connection, QString roomId, JoinState joinS
setFileUploadingProgress(0);
setHasFileUploading(false);
});
connect(this, &NeoChatRoom::notificationCountChanged, this, [this]() {
if(messageEvents().size() == 0)
return;
const RoomEvent *lastEvent = messageEvents().rbegin()->get();
if (lastEvent->isStateEvent())
return;
User *sender = user(lastEvent->senderId());
if (sender == localUser())
return;
NotificationsManager::instance().postNotification(id(), lastEvent->id(), displayName(), sender->displayname(this), eventToString(*lastEvent), avatar(128));
});
}
void NeoChatRoom::uploadFile(const QUrl &url, const QString &body)