Fix some miscellaneous weirdness around push notifications
For some reason, I *stopped* the timer if we get a push message - which
makes *no* sense. It meant that NeoChat kept running in the background
for basically no reason.
We can also make the NotificationsManager::postPushNotification function
static and avoid creating some singletons.
(cherry picked from commit 94ea1305b2)
This commit is contained in:
@@ -318,8 +318,7 @@ void Controller::listenForNotifications()
|
|||||||
connect(timer, &QTimer::timeout, qGuiApp, &QGuiApplication::quit);
|
connect(timer, &QTimer::timeout, qGuiApp, &QGuiApplication::quit);
|
||||||
|
|
||||||
connect(connector, &KUnifiedPush::Connector::messageReceived, [timer](const QByteArray &data) {
|
connect(connector, &KUnifiedPush::Connector::messageReceived, [timer](const QByteArray &data) {
|
||||||
instance().m_notificationsManager.postPushNotification(data);
|
NotificationsManager::postPushNotification(data);
|
||||||
timer->stop();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// Wait five seconds to see if we received any messages or this happened to be an erroneous activation.
|
// Wait five seconds to see if we received any messages or this happened to be an erroneous activation.
|
||||||
|
|||||||
@@ -389,7 +389,7 @@ void NotificationsManager::postPushNotification(const QByteArray &message)
|
|||||||
|
|
||||||
#ifdef HAVE_KIO
|
#ifdef HAVE_KIO
|
||||||
auto openAction = notification->addAction(i18n("Open NeoChat"));
|
auto openAction = notification->addAction(i18n("Open NeoChat"));
|
||||||
connect(openAction, &KNotificationAction::activated, this, [=]() {
|
connect(openAction, &KNotificationAction::activated, notification, [=]() {
|
||||||
QString properId = roomId;
|
QString properId = roomId;
|
||||||
properId = properId.replace(u"#"_s, QString());
|
properId = properId.replace(u"#"_s, QString());
|
||||||
properId = properId.replace(u"!"_s, QString());
|
properId = properId.replace(u"!"_s, QString());
|
||||||
@@ -403,8 +403,6 @@ void NotificationsManager::postPushNotification(const QByteArray &message)
|
|||||||
connect(notification, &KNotification::closed, qGuiApp, &QGuiApplication::quit);
|
connect(notification, &KNotification::closed, qGuiApp, &QGuiApplication::quit);
|
||||||
|
|
||||||
notification->sendEvent();
|
notification->sendEvent();
|
||||||
|
|
||||||
m_notifications.insert(roomId, {json["ts"_L1].toVariant().toLongLong(), notification});
|
|
||||||
} else {
|
} else {
|
||||||
qWarning() << "Skipping unsupported push notification" << type;
|
qWarning() << "Skipping unsupported push notification" << type;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ public:
|
|||||||
/**
|
/**
|
||||||
* @brief Display a native notification for the given push notification.
|
* @brief Display a native notification for the given push notification.
|
||||||
*/
|
*/
|
||||||
void postPushNotification(const QByteArray &message);
|
static void postPushNotification(const QByteArray &message);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Handle the notifications for the given connection.
|
* @brief Handle the notifications for the given connection.
|
||||||
|
|||||||
Reference in New Issue
Block a user