Improve the notification setting description

The current text has invited a lot of confusion around how notifications
work in NeoChat, because it mentions "push notifications". Some users
take it to mean that somehow the notifications appear in the background,
but that's only supported if built with KUnifiedPush.

To make it super clear, let's change the description dynamically based
on whether:
1. NeoChat is built with KUnifiedPush support.
2. We were able to connect with the KUnifiedPush daemon and your server
has a push gateway.
This commit is contained in:
Joshua Goins
2025-02-22 10:33:52 -05:00
parent 4725410c0f
commit e060032e6a
3 changed files with 43 additions and 1 deletions

View File

@@ -472,9 +472,12 @@ QCoro::Task<void> NeoChatConnection::setupPushNotifications(QString endpoint)
false);
qInfo() << "Registered for push notifications";
m_pushNotificationsEnabled = true;
} else {
qWarning() << "There's no gateway, not setting up push notifications.";
m_pushNotificationsEnabled = false;
}
Q_EMIT enablePushNotificationsChanged();
#else
Q_UNUSED(endpoint)
co_return;
@@ -536,4 +539,18 @@ bool NeoChatConnection::canEraseData() const
return m_canEraseData;
}
bool NeoChatConnection::pushNotificationsAvailable() const
{
#ifdef HAVE_KUNIFIEDPUSH
return true;
#else
return false;
#endif
}
bool NeoChatConnection::enablePushNotifications() const
{
return m_pushNotificationsEnabled;
}
#include "moc_neochatconnection.cpp"

View File

@@ -90,6 +90,16 @@ class NeoChatConnection : public Quotient::Connection
*/
Q_PROPERTY(bool canEraseData READ canEraseData NOTIFY canEraseDataChanged)
/**
* @brief Whether this build of NeoChat supports push notifications via KUnifiedPush.
*/
Q_PROPERTY(bool pushNotificationsAvailable READ pushNotificationsAvailable CONSTANT)
/**
* @brief Whether we successfully set up push notifications with the server.
*/
Q_PROPERTY(bool enablePushNotifications READ enablePushNotifications NOTIFY enablePushNotificationsChanged)
public:
/**
* @brief Defines the status after an attempt to change the password on an account.
@@ -178,6 +188,9 @@ public:
// the reference could be destroyed before the task is finished
QCoro::Task<void> setupPushNotifications(QString endpoint);
bool pushNotificationsAvailable() const;
bool enablePushNotifications() const;
bool isOnline() const;
LinkPreviewer *previewerForLink(const QUrl &link);
@@ -196,6 +209,7 @@ Q_SIGNALS:
void badgeNotificationCountChanged(NeoChatConnection *connection, int count);
void canCheckMutualRoomsChanged();
void canEraseDataChanged();
void enablePushNotificationsChanged();
/**
* @brief Request a message be shown to the user of the given type.
@@ -221,4 +235,5 @@ private:
bool m_canCheckMutualRooms = false;
bool m_canEraseData = false;
bool m_pushNotificationsEnabled = false;
};

View File

@@ -26,7 +26,17 @@ FormCard.FormCardPage {
Layout.topMargin: Kirigami.Units.largeSpacing * 4
FormCard.FormCheckDelegate {
text: i18n("Enable notifications for this account")
description: i18n("Whether push notifications are generated by your Matrix server")
description: {
if (connection.pushNotificationsAvailable) {
if (connection.enablePushNotifications) {
return i18n("Notifications can appear even when NeoChat isn't running.");
} else {
return i18n("Push notifications are available but could not be enabled.");
}
} else {
return i18n("Notifications will only appear when NeoChat is running.");
}
}
checked: root.pushRuleModel.globalNotificationsEnabled
enabled: root.pushRuleModel.globalNotificationsSet
onToggled: {